Use library const for HTTP verbs

This commit is contained in:
Juan Font Alonso 2022-09-04 11:33:00 +02:00
parent 68305df9b2
commit f4d197485c
2 changed files with 2 additions and 2 deletions

View File

@ -34,7 +34,7 @@ func loadDERPMapFromURL(addr url.URL) (*tailcfg.DERPMap, error) {
ctx, cancel := context.WithTimeout(context.Background(), HTTPReadTimeout) ctx, cancel := context.WithTimeout(context.Background(), HTTPReadTimeout)
defer cancel() defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", addr.String(), nil) req, err := http.NewRequestWithContext(ctx, http.MethodGet, addr.String(), nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -174,7 +174,7 @@ func (h *Headscale) DERPProbeHandler(
req *http.Request, req *http.Request,
) { ) {
switch req.Method { switch req.Method {
case "HEAD", "GET": case http.MethodHead, http.MethodGet:
writer.Header().Set("Access-Control-Allow-Origin", "*") writer.Header().Set("Access-Control-Allow-Origin", "*")
writer.WriteHeader(http.StatusOK) writer.WriteHeader(http.StatusOK)
default: default: