1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-06 00:10:23 +08:00
Files
paper-manager/backend/utils/method.go
2023-03-19 21:07:22 +08:00

19 lines
446 B
Go

package utils
import (
"net/http"
"github.com/sirupsen/logrus"
)
// IsMethod check if the method meets the requirement
// and response 405 Method Not Allowed if not matched
func IsMethod(m string, w http.ResponseWriter, r *http.Request) bool {
logrus.Infoln("[utils.IsMethod] accept", r.RemoteAddr, r.Method, r.URL)
if r.Method != m {
http.Error(w, "405 Method Not Allowed", http.StatusMethodNotAllowed)
return false
}
return true
}