diff options
author | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2019-07-18 08:40:10 +0100 |
---|---|---|
committer | Alex Chen <Cnly@users.noreply.github.com> | 2019-07-18 15:40:10 +0800 |
commit | 504d23f468caf6193431f2670c13315b43a84790 (patch) | |
tree | 68a91a9689b973ba17a181ae96350e6a23f8b8a8 /clientapi | |
parent | bff60953f36f87706546e49cd38fd7fc93727efa (diff) |
Remove unnecessary http method checks (#747)
Closes #523
There were a lot of unnecessary checks for HTTP methods of requests. gorilla/mux makes sure that these methods will only be called if certain HTTP methods are used, thus there's no reason to have these extra checks.
Diffstat (limited to 'clientapi')
-rw-r--r-- | clientapi/routing/account_data.go | 7 | ||||
-rw-r--r-- | clientapi/routing/device.go | 7 | ||||
-rw-r--r-- | clientapi/routing/filter.go | 12 | ||||
-rw-r--r-- | clientapi/routing/logout.go | 8 | ||||
-rw-r--r-- | clientapi/routing/profile.go | 6 |
5 files changed, 0 insertions, 40 deletions
diff --git a/clientapi/routing/account_data.go b/clientapi/routing/account_data.go index 30e00f72..d57a6d37 100644 --- a/clientapi/routing/account_data.go +++ b/clientapi/routing/account_data.go @@ -33,13 +33,6 @@ func SaveAccountData( req *http.Request, accountDB *accounts.Database, device *authtypes.Device, userID string, roomID string, dataType string, syncProducer *producers.SyncAPIProducer, ) util.JSONResponse { - if req.Method != http.MethodPut { - return util.JSONResponse{ - Code: http.StatusMethodNotAllowed, - JSON: jsonerror.NotFound("Bad method"), - } - } - if userID != device.UserID { return util.JSONResponse{ Code: http.StatusForbidden, diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go index cf6f24a7..c858e88a 100644 --- a/clientapi/routing/device.go +++ b/clientapi/routing/device.go @@ -106,13 +106,6 @@ func UpdateDeviceByID( req *http.Request, deviceDB *devices.Database, device *authtypes.Device, deviceID string, ) util.JSONResponse { - if req.Method != http.MethodPut { - return util.JSONResponse{ - Code: http.StatusMethodNotAllowed, - JSON: jsonerror.NotFound("Bad Method"), - } - } - localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID) if err != nil { return httputil.LogThenError(req, err) diff --git a/clientapi/routing/filter.go b/clientapi/routing/filter.go index 1ed91cd2..291a165b 100644 --- a/clientapi/routing/filter.go +++ b/clientapi/routing/filter.go @@ -32,12 +32,6 @@ import ( func GetFilter( req *http.Request, device *authtypes.Device, accountDB *accounts.Database, userID string, filterID string, ) util.JSONResponse { - if req.Method != http.MethodGet { - return util.JSONResponse{ - Code: http.StatusMethodNotAllowed, - JSON: jsonerror.NotFound("Bad method"), - } - } if userID != device.UserID { return util.JSONResponse{ Code: http.StatusForbidden, @@ -79,12 +73,6 @@ type filterResponse struct { func PutFilter( req *http.Request, device *authtypes.Device, accountDB *accounts.Database, userID string, ) util.JSONResponse { - if req.Method != http.MethodPost { - return util.JSONResponse{ - Code: http.StatusMethodNotAllowed, - JSON: jsonerror.NotFound("Bad method"), - } - } if userID != device.UserID { return util.JSONResponse{ Code: http.StatusForbidden, diff --git a/clientapi/routing/logout.go b/clientapi/routing/logout.go index d2013853..3294fbcd 100644 --- a/clientapi/routing/logout.go +++ b/clientapi/routing/logout.go @@ -20,7 +20,6 @@ import ( "github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/clientapi/auth/storage/devices" "github.com/matrix-org/dendrite/clientapi/httputil" - "github.com/matrix-org/dendrite/clientapi/jsonerror" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" ) @@ -29,13 +28,6 @@ import ( func Logout( req *http.Request, deviceDB *devices.Database, device *authtypes.Device, ) util.JSONResponse { - if req.Method != http.MethodPost { - return util.JSONResponse{ - Code: http.StatusMethodNotAllowed, - JSON: jsonerror.NotFound("Bad method"), - } - } - localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID) if err != nil { return httputil.LogThenError(req, err) diff --git a/clientapi/routing/profile.go b/clientapi/routing/profile.go index eb1acab7..034b9ac8 100644 --- a/clientapi/routing/profile.go +++ b/clientapi/routing/profile.go @@ -37,12 +37,6 @@ import ( func GetProfile( req *http.Request, accountDB *accounts.Database, userID string, asAPI appserviceAPI.AppServiceQueryAPI, ) util.JSONResponse { - if req.Method != http.MethodGet { - return util.JSONResponse{ - Code: http.StatusMethodNotAllowed, - JSON: jsonerror.NotFound("Bad method"), - } - } profile, err := appserviceAPI.RetrieveUserProfile(req.Context(), userID, asAPI, accountDB) if err != nil { return httputil.LogThenError(req, err) |