diff options
author | Ben Morrison <ben@gbmor.dev> | 2020-05-09 17:21:34 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2020-05-09 17:21:34 -0400 |
commit | 9b0d6aab1167a25400dae2a3c85cb4d08a7fa3cf (patch) | |
tree | 9b543cac1a4ae277f460ca651bcd6675b0aff722 /http.go | |
parent | 825c7e2cd4cc77024c20e31224e3d311196d8e80 (diff) | |
download | api-9b0d6aab1167a25400dae2a3c85cb4d08a7fa3cf.tar.gz |
cache.bap() now returns an error rather than handling the error silently
Diffstat (limited to 'http.go')
-rw-r--r-- | http.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/http.go b/http.go index 8ef76c5..e67560c 100644 --- a/http.go +++ b/http.go @@ -22,8 +22,11 @@ func mainHandler(w http.ResponseWriter, r *http.Request) { return } - cache.bap(r.URL.Path) - out, expires := cache.yoink(r.URL.Path) + err := cache.bap(r.URL.Path) + if err != nil { + errHTTP(w, r, err, http.StatusInternalServerError) + return + } if format == "json" { w.Header().Set("Content-Type", mimeJSON) @@ -31,9 +34,10 @@ func mainHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", mimePlain) } + out, expires := cache.yoink(r.URL.Path) w.Header().Set("Expires", expires) - _, err := w.Write(out) + _, err = w.Write(out) if err != nil { errHTTP(w, r, err, http.StatusBadRequest) return |