refactor: Add Go 1.22 HTTP method matching
This commit is contained in:
parent
bd94b295ac
commit
74a8db7d2b
3 changed files with 7 additions and 15 deletions
|
@ -10,8 +10,7 @@ import (
|
|||
"git.hamburg.ccc.de/ccchh/spaceapid/util"
|
||||
)
|
||||
|
||||
// updateEndpointValidator checks BasicAuth credentials,
|
||||
// checks for correct HTTP method and then returns the request body
|
||||
// updateEndpointValidator checks BasicAuth credentials and then returns the request body
|
||||
func updateEndpointValidator(
|
||||
authDB config.HTTPBACredentials, validCredentials []config.HTTPBACredentialID,
|
||||
w http.ResponseWriter, r *http.Request,
|
||||
|
@ -24,13 +23,6 @@ func updateEndpointValidator(
|
|||
return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password))
|
||||
}
|
||||
|
||||
// Check if PUT method
|
||||
if r.Method != http.MethodPut {
|
||||
w.Header().Set("Allow", http.MethodPut)
|
||||
http.Error(w, "", http.StatusMethodNotAllowed)
|
||||
return []byte{}, errors.New(fmt.Sprintf("Wrong Method: %s from %s at %s", r.Method, r.RemoteAddr, r.RequestURI))
|
||||
}
|
||||
|
||||
// Read request body
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue