add mutex lock
This commit is contained in:
parent
a4b764ad52
commit
ae62fd9c2b
1 changed files with 2 additions and 0 deletions
|
|
@ -55,7 +55,9 @@ func (h *visitsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if r.Method == http.MethodGet {
|
if r.Method == http.MethodGet {
|
||||||
|
h.store.Lock()
|
||||||
jsonBytes, err := json.Marshal(h.store.m)
|
jsonBytes, err := json.Marshal(h.store.m)
|
||||||
|
h.store.Unlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte("cannot serialize"))
|
w.Write([]byte("cannot serialize"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue