chore(lint): upgrade linter to v1.56.2
This commit is contained in:
@@ -32,10 +32,10 @@ func (h *dnsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case http.MethodPut:
|
||||
h.setStatus(w, r)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
default:
|
||||
http.Error(w, "route "+r.RequestURI+" not supported", http.StatusBadRequest)
|
||||
errRouteNotSupported(w, r.RequestURI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
13
internal/server/helpers.go
Normal file
13
internal/server/helpers.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func errMethodNotSupported(w http.ResponseWriter, method string) {
|
||||
http.Error(w, "method "+method+" not supported", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
func errRouteNotSupported(w http.ResponseWriter, route string) {
|
||||
http.Error(w, "route "+route+" not supported", http.StatusBadRequest)
|
||||
}
|
||||
@@ -34,24 +34,24 @@ func (h *openvpnHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case http.MethodPut:
|
||||
h.setStatus(w, r)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
case "/settings":
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
h.getSettings(w)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
case "/portforwarded":
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
h.getPortForwarded(w)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
default:
|
||||
http.Error(w, "route "+r.RequestURI+" not supported", http.StatusBadRequest)
|
||||
errRouteNotSupported(w, r.RequestURI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ func (h *publicIPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case http.MethodGet:
|
||||
h.getPublicIP(w)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
default:
|
||||
http.Error(w, "route "+r.RequestURI+" not supported", http.StatusBadRequest)
|
||||
errRouteNotSupported(w, r.RequestURI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ func (h *updaterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case http.MethodPut:
|
||||
h.setStatus(w, r)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
default:
|
||||
http.Error(w, "route "+r.RequestURI+" not supported", http.StatusBadRequest)
|
||||
errRouteNotSupported(w, r.RequestURI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func (h *vpnHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case http.MethodPut:
|
||||
h.setStatus(w, r)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
case "/settings":
|
||||
switch r.Method {
|
||||
@@ -47,10 +47,10 @@ func (h *vpnHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case http.MethodPut:
|
||||
h.patchSettings(w, r)
|
||||
default:
|
||||
http.Error(w, "method "+r.Method+" not supported", http.StatusBadRequest)
|
||||
errMethodNotSupported(w, r.Method)
|
||||
}
|
||||
default:
|
||||
http.Error(w, "route "+r.RequestURI+" not supported", http.StatusBadRequest)
|
||||
errRouteNotSupported(w, r.RequestURI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user