summaryrefslogtreecommitdiffstats
path: root/api4/handlers.go
diff options
context:
space:
mode:
authorMartin Kraft <martinkraft@gmail.com>2018-05-15 07:45:28 -0400
committerMartin Kraft <martinkraft@gmail.com>2018-05-15 07:45:28 -0400
commitf82cc7896dd57c4c96471bcbbd2b1a39f908e5e7 (patch)
treed3899b890408f6f16b2d5f543bf975475f1a5584 /api4/handlers.go
parent51bd710ecdca6628461c9fa2679737073e4d5059 (diff)
parenta1656dffa98fbc8865e476b214e4e0c562547d39 (diff)
downloadchat-f82cc7896dd57c4c96471bcbbd2b1a39f908e5e7.tar.gz
chat-f82cc7896dd57c4c96471bcbbd2b1a39f908e5e7.tar.bz2
chat-f82cc7896dd57c4c96471bcbbd2b1a39f908e5e7.zip
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Diffstat (limited to 'api4/handlers.go')
-rw-r--r--api4/handlers.go67
1 files changed, 67 insertions, 0 deletions
diff --git a/api4/handlers.go b/api4/handlers.go
new file mode 100644
index 000000000..74e2fc88d
--- /dev/null
+++ b/api4/handlers.go
@@ -0,0 +1,67 @@
+// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package api4
+
+import (
+ "net/http"
+
+ "github.com/mattermost/mattermost-server/web"
+)
+
+type Context = web.Context
+
+func (api *API) ApiHandler(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler {
+ return &web.Handler{
+ App: api.App,
+ HandleFunc: h,
+ RequireSession: false,
+ TrustRequester: false,
+ RequireMfa: false,
+ IsStatic: false,
+ }
+}
+
+func (api *API) ApiSessionRequired(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler {
+ return &web.Handler{
+ App: api.App,
+ HandleFunc: h,
+ RequireSession: true,
+ TrustRequester: false,
+ RequireMfa: true,
+ IsStatic: false,
+ }
+}
+
+func (api *API) ApiSessionRequiredMfa(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler {
+ return &web.Handler{
+ App: api.App,
+ HandleFunc: h,
+ RequireSession: true,
+ TrustRequester: false,
+ RequireMfa: false,
+ IsStatic: false,
+ }
+}
+
+func (api *API) ApiHandlerTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler {
+ return &web.Handler{
+ App: api.App,
+ HandleFunc: h,
+ RequireSession: false,
+ TrustRequester: true,
+ RequireMfa: false,
+ IsStatic: false,
+ }
+}
+
+func (api *API) ApiSessionRequiredTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler {
+ return &web.Handler{
+ App: api.App,
+ HandleFunc: h,
+ RequireSession: true,
+ TrustRequester: true,
+ RequireMfa: true,
+ IsStatic: false,
+ }
+}