diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-06-13 22:52:36 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-06-13 22:52:36 -0400 |
commit | d20ad73467c0636edea6133d7bd4b38bbfdefc55 (patch) | |
tree | 9e4b3fa8b44fb18dfe3f78eed9d27da85a4e5a41 /svc/handlers.go | |
parent | 5d21ab1d75b6a4ef47a98f7be2e326bbd99bba51 (diff) | |
download | getwtxt-d20ad73467c0636edea6133d7bd4b38bbfdefc55.tar.gz |
mutex and readability cleanup
Diffstat (limited to 'svc/handlers.go')
-rw-r--r-- | svc/handlers.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/svc/handlers.go b/svc/handlers.go index 924b487..973bd62 100644 --- a/svc/handlers.go +++ b/svc/handlers.go @@ -20,14 +20,14 @@ func getEtag(modtime time.Time) string { func servStatic(w http.ResponseWriter, isCSS bool) error { pingAssets() - staticCache.mu.RLock() + defer staticCache.mu.RUnlock() + if isCSS { etag := getEtag(staticCache.cssMod) w.Header().Set("ETag", "\""+etag+"\"") w.Header().Set("Content-Type", cssutf8) _, err := w.Write(staticCache.css) - staticCache.mu.RUnlock() return err } @@ -35,7 +35,6 @@ func servStatic(w http.ResponseWriter, isCSS bool) error { w.Header().Set("ETag", "\""+etag+"\"") w.Header().Set("Content-Type", htmlutf8) _, err := w.Write(staticCache.index) - staticCache.mu.RUnlock() return err } |