mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-20 16:44:27 +01:00
replacing label parser map with improved deserialization implementation, API host check now disabled when in debug mode
This commit is contained in:
@@ -40,10 +40,13 @@ func NewHandler(cfg *config.Config) http.Handler {
|
||||
|
||||
// allow only requests to API server with host matching common.APIHTTPAddr
|
||||
func checkHost(f http.HandlerFunc) http.HandlerFunc {
|
||||
if common.IsDebug {
|
||||
return f
|
||||
}
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Host != common.APIHTTPAddr {
|
||||
Logger.Warnf("invalid request to API server with host: %s, expect %s", r.Host, common.APIHTTPAddr)
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
w.Write([]byte("invalid request"))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user