diff --git a/clientapi/routing/register_secret.go b/clientapi/routing/register_secret.go index e55c74da3..f0436e322 100644 --- a/clientapi/routing/register_secret.go +++ b/clientapi/routing/register_secret.go @@ -1,6 +1,7 @@ package routing import ( + "context" "crypto/hmac" "crypto/sha1" "encoding/hex" @@ -11,6 +12,7 @@ import ( "strings" "time" + "github.com/matrix-org/dendrite/internal" "github.com/matrix-org/util" cache "github.com/patrickmn/go-cache" ) @@ -25,7 +27,7 @@ type SharedSecretRegistrationRequest struct { } func NewSharedSecretRegistrationRequest(reader io.ReadCloser) (*SharedSecretRegistrationRequest, error) { - defer reader.Close() + defer internal.CloseAndLogIfError(context.Background(), reader, "NewSharedSecretRegistrationRequest: failed to close request body") var ssrr SharedSecretRegistrationRequest err := json.NewDecoder(reader).Decode(&ssrr) if err != nil { diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 168f2ea22..37279e8ed 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -94,7 +94,7 @@ func Setup( sr := NewSharedSecretRegistration(cfg.RegistrationSharedSecret) synapseAdminRouter.Handle("/admin/v1/register", httputil.MakeExternalAPI("shared_secret_registration", func(req *http.Request) util.JSONResponse { - if req.Method == "GET" { + if req.Method == http.MethodGet { return util.JSONResponse{ Code: 200, JSON: struct { @@ -104,7 +104,7 @@ func Setup( }, } } - if req.Method == "POST" { + if req.Method == http.MethodPost { return handleSharedSecretRegistration(userAPI, sr, req) } return util.JSONResponse{