This commit is contained in:
Kegan Dougal 2021-07-09 16:26:38 +01:00
parent 6e04b8022d
commit 02a6f9b8ec
2 changed files with 5 additions and 3 deletions

View file

@ -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 {

View file

@ -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{