summaryrefslogtreecommitdiffstats
path: root/api4/api.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-12 09:19:52 -0500
committerGitHub <noreply@github.com>2017-09-12 09:19:52 -0500
commitb066b6df138e88e75cb40f1ec3e58fbd13e61909 (patch)
tree7ee0e8c935cd3bbafd15d0d07d8900af8b82a4e0 /api4/api.go
parent674a606bd00b276d0a05b3b29a3d5f5e5e7f8206 (diff)
downloadchat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.tar.gz
chat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.tar.bz2
chat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.zip
Remove global app references (#7433)
* remove global app references * test fix * fix api4 test compilation
Diffstat (limited to 'api4/api.go')
-rw-r--r--api4/api.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/api4/api.go b/api4/api.go
index 50c56ca0b..7b3beaf40 100644
--- a/api4/api.go
+++ b/api4/api.go
@@ -105,15 +105,16 @@ type Routes struct {
var BaseRoutes *Routes
-func InitRouter() {
- app.Global().Srv.Router = mux.NewRouter()
- app.Global().Srv.Router.NotFoundHandler = http.HandlerFunc(Handle404)
+func NewRouter() *mux.Router {
+ ret := mux.NewRouter()
+ ret.NotFoundHandler = http.HandlerFunc(Handle404)
+ return ret
}
-func InitApi(full bool) {
+func InitApi(root *mux.Router, full bool) {
BaseRoutes = &Routes{}
- BaseRoutes.Root = app.Global().Srv.Router
- BaseRoutes.ApiRoot = app.Global().Srv.Router.PathPrefix(model.API_URL_SUFFIX).Subrouter()
+ BaseRoutes.Root = root
+ BaseRoutes.ApiRoot = root.PathPrefix(model.API_URL_SUFFIX).Subrouter()
BaseRoutes.Users = BaseRoutes.ApiRoot.PathPrefix("/users").Subrouter()
BaseRoutes.User = BaseRoutes.ApiRoot.PathPrefix("/users/{user_id:[A-Za-z0-9]+}").Subrouter()
@@ -213,7 +214,7 @@ func InitApi(full bool) {
InitOpenGraph()
InitPlugin()
- app.Global().Srv.Router.Handle("/api/v4/{anything:.*}", http.HandlerFunc(Handle404))
+ root.Handle("/api/v4/{anything:.*}", http.HandlerFunc(Handle404))
// REMOVE CONDITION WHEN APIv3 REMOVED
if full {