diff --git a/birdtown-visit-counter.go b/birdtown-visit-counter.go index 6bf4f1e..064241e 100644 --- a/birdtown-visit-counter.go +++ b/birdtown-visit-counter.go @@ -55,7 +55,9 @@ func (h *visitsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } if r.Method == http.MethodGet { + h.store.Lock() jsonBytes, err := json.Marshal(h.store.m) + h.store.Unlock() if err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("cannot serialize"))