diff options
| -rw-r--r-- | weed/command/compact.go | 2 | ||||
| -rw-r--r-- | weed/server/filer_server_handlers.go | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/weed/command/compact.go b/weed/command/compact.go index 6d1f5d5f1..6f5f2307a 100644 --- a/weed/command/compact.go +++ b/weed/command/compact.go @@ -28,7 +28,7 @@ var ( compactVolumePath = cmdCompact.Flag.String("dir", ".", "data directory to store files") compactVolumeCollection = cmdCompact.Flag.String("collection", "", "volume collection name") compactVolumeId = cmdCompact.Flag.Int("volumeId", -1, "a volume id. The volume should already exist in the dir.") - compactMethod = cmdCompact.Flag.Int("method", 0, "option to choose which compact method. use 0 or 1.") + compactMethod = cmdCompact.Flag.Int("method", 0, "option to choose which compact method. use 0 (default) or 1.") compactVolumePreallocate = cmdCompact.Flag.Int64("preallocateMB", 0, "preallocate volume disk space") ) diff --git a/weed/server/filer_server_handlers.go b/weed/server/filer_server_handlers.go index b5e070fb2..33f63f65a 100644 --- a/weed/server/filer_server_handlers.go +++ b/weed/server/filer_server_handlers.go @@ -63,11 +63,11 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { stats.FilerRequestHistogram.WithLabelValues(stats.ChunkProxy).Observe(time.Since(start).Seconds()) return } - - defer func() { - stats.FilerRequestCounter.WithLabelValues(r.Method, strconv.Itoa(statusRecorder.Status)).Inc() - stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds()) - }() + requestMethod := r.Method + defer func(method *string) { + stats.FilerRequestCounter.WithLabelValues(*method, strconv.Itoa(statusRecorder.Status)).Inc() + stats.FilerRequestHistogram.WithLabelValues(*method).Observe(time.Since(start).Seconds()) + }(&requestMethod) isReadHttpCall := r.Method == http.MethodGet || r.Method == http.MethodHead if !fs.maybeCheckJwtAuthorization(r, !isReadHttpCall) { @@ -113,6 +113,7 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) { fs.PostHandler(w, r, contentLength) } default: + requestMethod = "INVALID" w.WriteHeader(http.StatusMethodNotAllowed) } } @@ -146,11 +147,11 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque w.Header().Set("Access-Control-Allow-Headers", "OPTIONS, GET, HEAD") w.Header().Set("Access-Control-Allow-Credentials", "true") } - - defer func() { - stats.FilerRequestCounter.WithLabelValues(r.Method, strconv.Itoa(statusRecorder.Status)).Inc() - stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds()) - }() + requestMethod := r.Method + defer func(method *string) { + stats.FilerRequestCounter.WithLabelValues(*method, strconv.Itoa(statusRecorder.Status)).Inc() + stats.FilerRequestHistogram.WithLabelValues(*method).Observe(time.Since(start).Seconds()) + }(&requestMethod) // We handle OPTIONS first because it never should be authenticated if r.Method == http.MethodOptions { OptionsHandler(w, r, true) @@ -168,6 +169,7 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque case http.MethodGet, http.MethodHead: fs.GetOrHeadHandler(w, r) default: + requestMethod = "INVALID" w.WriteHeader(http.StatusMethodNotAllowed) } } |
