Replace Hard-coded HTTP Verbs with Constants (#27219)
* Replace hard-coded HTTP verbs with constants in `net/http`
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e364c2a265
Коммит
d44c3d5d45
@@ -21,83 +21,83 @@ import (
|
||||
|
||||
func (api *API) InitGroup() {
|
||||
// GET /api/v4/groups
|
||||
api.BaseRoutes.Groups.Handle("", api.APISessionRequired(getGroups)).Methods("GET")
|
||||
api.BaseRoutes.Groups.Handle("", api.APISessionRequired(getGroups)).Methods(http.MethodGet)
|
||||
|
||||
// POST /api/v4/groups
|
||||
api.BaseRoutes.Groups.Handle("", api.APISessionRequired(createGroup)).Methods("POST")
|
||||
api.BaseRoutes.Groups.Handle("", api.APISessionRequired(createGroup)).Methods(http.MethodPost)
|
||||
|
||||
// GET /api/v4/groups/:group_id
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}",
|
||||
api.APISessionRequired(getGroup)).Methods("GET")
|
||||
api.APISessionRequired(getGroup)).Methods(http.MethodGet)
|
||||
|
||||
// PUT /api/v4/groups/:group_id/patch
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/patch",
|
||||
api.APISessionRequired(patchGroup)).Methods("PUT")
|
||||
api.APISessionRequired(patchGroup)).Methods(http.MethodPut)
|
||||
|
||||
// POST /api/v4/groups/:group_id/teams/:team_id/link
|
||||
// POST /api/v4/groups/:group_id/channels/:channel_id/link
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/{syncable_type:teams|channels}/{syncable_id:[A-Za-z0-9]+}/link",
|
||||
api.APISessionRequired(linkGroupSyncable)).Methods("POST")
|
||||
api.APISessionRequired(linkGroupSyncable)).Methods(http.MethodPost)
|
||||
|
||||
// DELETE /api/v4/groups/:group_id/teams/:team_id/link
|
||||
// DELETE /api/v4/groups/:group_id/channels/:channel_id/link
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/{syncable_type:teams|channels}/{syncable_id:[A-Za-z0-9]+}/link",
|
||||
api.APISessionRequired(unlinkGroupSyncable)).Methods("DELETE")
|
||||
api.APISessionRequired(unlinkGroupSyncable)).Methods(http.MethodDelete)
|
||||
|
||||
// GET /api/v4/groups/:group_id/teams/:team_id
|
||||
// GET /api/v4/groups/:group_id/channels/:channel_id
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/{syncable_type:teams|channels}/{syncable_id:[A-Za-z0-9]+}",
|
||||
api.APISessionRequired(getGroupSyncable)).Methods("GET")
|
||||
api.APISessionRequired(getGroupSyncable)).Methods(http.MethodGet)
|
||||
|
||||
// GET /api/v4/groups/:group_id/teams
|
||||
// GET /api/v4/groups/:group_id/channels
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/{syncable_type:teams|channels}",
|
||||
api.APISessionRequired(getGroupSyncables)).Methods("GET")
|
||||
api.APISessionRequired(getGroupSyncables)).Methods(http.MethodGet)
|
||||
|
||||
// PUT /api/v4/groups/:group_id/teams/:team_id/patch
|
||||
// PUT /api/v4/groups/:group_id/channels/:channel_id/patch
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/{syncable_type:teams|channels}/{syncable_id:[A-Za-z0-9]+}/patch",
|
||||
api.APISessionRequired(patchGroupSyncable)).Methods("PUT")
|
||||
api.APISessionRequired(patchGroupSyncable)).Methods(http.MethodPut)
|
||||
|
||||
// GET /api/v4/groups/:group_id/stats
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/stats",
|
||||
api.APISessionRequired(getGroupStats)).Methods("GET")
|
||||
api.APISessionRequired(getGroupStats)).Methods(http.MethodGet)
|
||||
|
||||
// GET /api/v4/groups/:group_id/members
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/members",
|
||||
api.APISessionRequired(getGroupMembers)).Methods("GET")
|
||||
api.APISessionRequired(getGroupMembers)).Methods(http.MethodGet)
|
||||
|
||||
// GET /api/v4/users/:user_id/groups
|
||||
api.BaseRoutes.Users.Handle("/{user_id:[A-Za-z0-9]+}/groups",
|
||||
api.APISessionRequired(getGroupsByUserId)).Methods("GET")
|
||||
api.APISessionRequired(getGroupsByUserId)).Methods(http.MethodGet)
|
||||
|
||||
// GET /api/v4/channels/:channel_id/groups
|
||||
api.BaseRoutes.Channels.Handle("/{channel_id:[A-Za-z0-9]+}/groups",
|
||||
api.APISessionRequired(getGroupsByChannel)).Methods("GET")
|
||||
api.APISessionRequired(getGroupsByChannel)).Methods(http.MethodGet)
|
||||
|
||||
// GET /api/v4/teams/:team_id/groups
|
||||
api.BaseRoutes.Teams.Handle("/{team_id:[A-Za-z0-9]+}/groups",
|
||||
api.APISessionRequired(getGroupsByTeam)).Methods("GET")
|
||||
api.APISessionRequired(getGroupsByTeam)).Methods(http.MethodGet)
|
||||
|
||||
// GET /api/v4/teams/:team_id/groups_by_channels
|
||||
api.BaseRoutes.Teams.Handle("/{team_id:[A-Za-z0-9]+}/groups_by_channels",
|
||||
api.APISessionRequired(getGroupsAssociatedToChannelsByTeam)).Methods("GET")
|
||||
api.APISessionRequired(getGroupsAssociatedToChannelsByTeam)).Methods(http.MethodGet)
|
||||
|
||||
// DELETE /api/v4/groups/:group_id
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}",
|
||||
api.APISessionRequired(deleteGroup)).Methods("DELETE")
|
||||
api.APISessionRequired(deleteGroup)).Methods(http.MethodDelete)
|
||||
|
||||
// POST /api/v4/groups/:group_id
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/restore",
|
||||
api.APISessionRequired(restoreGroup)).Methods("POST")
|
||||
api.APISessionRequired(restoreGroup)).Methods(http.MethodPost)
|
||||
|
||||
// POST /api/v4/groups/:group_id/members
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/members",
|
||||
api.APISessionRequired(addGroupMembers)).Methods("POST")
|
||||
api.APISessionRequired(addGroupMembers)).Methods(http.MethodPost)
|
||||
|
||||
// DELETE /api/v4/groups/:group_id/members
|
||||
api.BaseRoutes.Groups.Handle("/{group_id:[A-Za-z0-9]+}/members",
|
||||
api.APISessionRequired(deleteGroupMembers)).Methods("DELETE")
|
||||
api.APISessionRequired(deleteGroupMembers)).Methods(http.MethodDelete)
|
||||
}
|
||||
|
||||
func getGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Ссылка в новой задаче
Block a user