summaryrefslogtreecommitdiffstats
path: root/api4/api.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-05-14 10:24:58 -0400
committerGitHub <noreply@github.com>2018-05-14 10:24:58 -0400
commit47250c6629416b628a19e5571ac89f7b4646418c (patch)
tree0ccfd50e06af7293e0f9e27c2d1c1200efa78a6a /api4/api.go
parent7e7c55198719337e7cb39b07c0d5a48c0a6908de (diff)
downloadchat-47250c6629416b628a19e5571ac89f7b4646418c.tar.gz
chat-47250c6629416b628a19e5571ac89f7b4646418c.tar.bz2
chat-47250c6629416b628a19e5571ac89f7b4646418c.zip
Refactor context out of API packages (#8755)
* Refactor context out of API packages * Update function names per feedback * Move webhook handlers to web and fix web tests * Move more webhook tests out of api package * Fix static handler
Diffstat (limited to 'api4/api.go')
-rw-r--r--api4/api.go16
1 files changed, 4 insertions, 12 deletions
diff --git a/api4/api.go b/api4/api.go
index d36c3e3ee..acce923c0 100644
--- a/api4/api.go
+++ b/api4/api.go
@@ -4,14 +4,12 @@
package api4
import (
- "fmt"
"net/http"
"github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/app"
- "github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
- "github.com/mattermost/mattermost-server/utils"
+ "github.com/mattermost/mattermost-server/web"
_ "github.com/nicksnyder/go-i18n/i18n"
)
@@ -231,7 +229,7 @@ func Init(a *app.App, root *mux.Router, full bool) *API {
api.InitRole()
api.InitImage()
- root.Handle("/api/v4/{anything:.*}", http.HandlerFunc(Handle404))
+ root.Handle("/api/v4/{anything:.*}", http.HandlerFunc(api.Handle404))
// REMOVE CONDITION WHEN APIv3 REMOVED
if full {
@@ -241,14 +239,8 @@ func Init(a *app.App, root *mux.Router, full bool) *API {
return api
}
-func Handle404(w http.ResponseWriter, r *http.Request) {
- err := model.NewAppError("Handle404", "api.context.404.app_error", nil, "", http.StatusNotFound)
-
- mlog.Debug(fmt.Sprintf("%v: code=404 ip=%v", r.URL.Path, utils.GetIpAddress(r)))
-
- w.WriteHeader(err.StatusCode)
- err.DetailedError = "There doesn't appear to be an api call for the url='" + r.URL.Path + "'."
- w.Write([]byte(err.ToJson()))
+func (api *API) Handle404(w http.ResponseWriter, r *http.Request) {
+ web.Handle404(api.App, w, r)
}
func ReturnStatusOK(w http.ResponseWriter) {