package main import ( "fmt" "net/http" ) func (cfg *apiConfig) middlewareMetricsInc(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { cfg.fileserverHits.Add(1) next.ServeHTTP(w, req) }) } func (cfg *apiConfig) serveMetrics(w http.ResponseWriter, r *http.Request) { hits := cfg.fileserverHits.Load() fmt.Fprintf(w, "Hits: %d", hits) }