最後活躍 1 month ago

mila 已修改 2 years ago. 還原成這個修訂版本

沒有任何變更

mila 已修改 2 years ago. 還原成這個修訂版本

1 file changed, 2 insertions

gistfile1.txt 重命名為 http-metrics.go

@@ -1,5 +1,7 @@
1 1 import "github.com/felixge/httpsnoop"
2 2
3 + handler := http.StripPrefix("/path/", http.FileServer(http.Dir("/tmp/files/")))
4 +
3 5 wrappedHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
4 6 metrics := httpsnoop.CaptureMetrics(handler, w, r)
5 7 slog.Info(fmt.Sprintf("%v %v", r.Method, r.URL), "code", metrics.Code)

mila 已修改 2 years ago. 還原成這個修訂版本

1 file changed, 6 insertions

gistfile1.txt(檔案已創建)

@@ -0,0 +1,6 @@
1 + import "github.com/felixge/httpsnoop"
2 +
3 + wrappedHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
4 + metrics := httpsnoop.CaptureMetrics(handler, w, r)
5 + slog.Info(fmt.Sprintf("%v %v", r.Method, r.URL), "code", metrics.Code)
6 + })
上一頁 下一頁