summaryrefslogtreecommitdiffstats
path: root/api4/params.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-01-30 08:30:02 -0500
committerGitHub <noreply@github.com>2017-01-30 08:30:02 -0500
commitc01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e (patch)
treef995a08e296b5088df2a882ab70251c7b2b8cfe7 /api4/params.go
parent3e2f879b77b9b9d089bc8f83304b8b21b83c5bd9 (diff)
downloadchat-c01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e.tar.gz
chat-c01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e.tar.bz2
chat-c01d9ad6cf3f8bb2ad4145441816598d8ffa2d9e.zip
Implement APIv4 infrastructure (#5191)
* Implement APIv4 infrastructure * Update parameter requirement functions per feedback
Diffstat (limited to 'api4/params.go')
-rw-r--r--api4/params.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/api4/params.go b/api4/params.go
new file mode 100644
index 000000000..452b9ba21
--- /dev/null
+++ b/api4/params.go
@@ -0,0 +1,61 @@
+// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package api4
+
+import (
+ "net/http"
+
+ "github.com/gorilla/mux"
+)
+
+type ApiParams struct {
+ UserId string
+ TeamId string
+ ChannelId string
+ PostId string
+ FileId string
+ CommandId string
+ HookId string
+ EmojiId string
+}
+
+func ApiParamsFromRequest(r *http.Request) *ApiParams {
+ params := &ApiParams{}
+
+ props := mux.Vars(r)
+
+ if val, ok := props["user_id"]; ok {
+ params.UserId = val
+ }
+
+ if val, ok := props["team_id"]; ok {
+ params.TeamId = val
+ }
+
+ if val, ok := props["channel_id"]; ok {
+ params.ChannelId = val
+ }
+
+ if val, ok := props["post_id"]; ok {
+ params.PostId = val
+ }
+
+ if val, ok := props["file_id"]; ok {
+ params.FileId = val
+ }
+
+ if val, ok := props["command_id"]; ok {
+ params.CommandId = val
+ }
+
+ if val, ok := props["hook_id"]; ok {
+ params.HookId = val
+ }
+
+ if val, ok := props["emoji_id"]; ok {
+ params.EmojiId = val
+ }
+
+ return params
+}