Code Room
Code reviewMedium
Question
Review this Go HTTP handler that counts requests per endpoint.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
var hits = map[string]int{} func handler(w http.ResponseWriter, r *http.Request) { path := r.URL.Path hits[path]++ fmt.Fprintf(w, "path %s seen %d times\n", path, hits[path])} func statsHandler(w http.ResponseWriter, r *http.Request) { for p, n := range hits { fmt.Fprintf(w, "%s = %d\n", p, n) }} func main() { http.HandleFunc("/", handler) http.HandleFunc("/stats", statsHandler) http.ListenAndServe(":8080", nil)}Run or narrate your approach, then ask the coach.