16535: Use package consts for http methods.
authorTom Clegg <tom@tomclegg.ca>
Tue, 18 Aug 2020 19:34:28 +0000 (15:34 -0400)
committerTom Clegg <tom@tomclegg.ca>
Tue, 18 Aug 2020 19:34:28 +0000 (15:34 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

services/keep-web/s3.go

index c774275407d68910a351cf9628330339ffa64139..12e294d9339710f861a491518c5dcb4d541f2f10 100644 (file)
@@ -68,7 +68,7 @@ func (h *handler) serveS3(w http.ResponseWriter, r *http.Request) bool {
        objectNameGiven := strings.Count(strings.TrimSuffix(r.URL.Path, "/"), "/") > 1
 
        switch {
-       case r.Method == "GET" && !objectNameGiven:
+       case r.Method == http.MethodGet && !objectNameGiven:
                // Path is "/{uuid}" or "/{uuid}/", has no object name
                if _, ok := r.URL.Query()["versioning"]; ok {
                        // GetBucketVersioning
@@ -80,7 +80,7 @@ func (h *handler) serveS3(w http.ResponseWriter, r *http.Request) bool {
                        h.s3list(w, r, fs)
                }
                return true
-       case r.Method == "GET" || r.Method == "HEAD":
+       case r.Method == http.MethodGet || r.Method == http.MethodHead:
                fspath := "/by_id" + r.URL.Path
                fi, err := fs.Stat(fspath)
                if r.Method == "HEAD" && !objectNameGiven {
@@ -110,7 +110,7 @@ func (h *handler) serveS3(w http.ResponseWriter, r *http.Request) bool {
                r.URL.Path = fspath
                http.FileServer(fs).ServeHTTP(w, &r)
                return true
-       case r.Method == "PUT":
+       case r.Method == http.MethodPut:
                if !objectNameGiven {
                        http.Error(w, "missing object name in PUT request", http.StatusBadRequest)
                        return true