From 9b0d6aab1167a25400dae2a3c85cb4d08a7fa3cf Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Sat, 9 May 2020 17:21:34 -0400 Subject: cache.bap() now returns an error rather than handling the error silently --- http.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'http.go') 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 -- cgit 1.4.1-2-gfad0