summaryrefslogtreecommitdiffstats
path: root/api/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'api/api.go')
-rw-r--r--api/api.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/api/api.go b/api/api.go
index 122a6b933..59c547b8c 100644
--- a/api/api.go
+++ b/api/api.go
@@ -7,6 +7,7 @@ import (
"net/http"
"github.com/gorilla/mux"
+ "github.com/mattermost/platform/app"
"github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
@@ -53,16 +54,20 @@ type Routes struct {
Emoji *mux.Router // 'api/v3/emoji'
Webrtc *mux.Router // 'api/v3/webrtc'
-
- WebSocket *WebSocketRouter // websocket api
}
var BaseRoutes *Routes
+func InitRouter() {
+ app.Srv.Router = mux.NewRouter()
+ app.Srv.Router.NotFoundHandler = http.HandlerFunc(Handle404)
+ app.Srv.WebSocketRouter = app.NewWebSocketRouter()
+}
+
func InitApi() {
BaseRoutes = &Routes{}
- BaseRoutes.Root = Srv.Router
- BaseRoutes.ApiRoot = Srv.Router.PathPrefix(model.API_URL_SUFFIX).Subrouter()
+ BaseRoutes.Root = app.Srv.Router
+ BaseRoutes.ApiRoot = app.Srv.Router.PathPrefix(model.API_URL_SUFFIX).Subrouter()
BaseRoutes.Users = BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter()
BaseRoutes.NeedUser = BaseRoutes.Users.PathPrefix("/{user_id:[A-Za-z0-9]+}").Subrouter()
BaseRoutes.Teams = BaseRoutes.ApiRoot.PathPrefix("/teams").Subrouter()
@@ -86,8 +91,6 @@ func InitApi() {
BaseRoutes.Emoji = BaseRoutes.ApiRoot.PathPrefix("/emoji").Subrouter()
BaseRoutes.Webrtc = BaseRoutes.ApiRoot.PathPrefix("/webrtc").Subrouter()
- BaseRoutes.WebSocket = NewWebSocketRouter()
-
InitUser()
InitTeam()
InitChannel()
@@ -108,11 +111,11 @@ func InitApi() {
InitDeprecated()
// 404 on any api route before web.go has a chance to serve it
- Srv.Router.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))
+ app.Srv.Router.Handle("/api/{anything:.*}", http.HandlerFunc(Handle404))
utils.InitHTML()
- InitEmailBatching()
+ app.InitEmailBatching()
}
func HandleEtag(etag string, routeName string, w http.ResponseWriter, r *http.Request) bool {