From c0ad2028fb4c8f1cc9eec89a7fa86dcb552609ab Mon Sep 17 00:00:00 2001 From: mlabusch Date: Fri, 12 May 2017 11:15:54 +0200 Subject: [PATCH] [TASK] add freshness --- http/good_show.go | 6 ++++-- webroot/index.html | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/http/good_show.go b/http/good_show.go index 507bbfe..d10b157 100644 --- a/http/good_show.go +++ b/http/good_show.go @@ -99,8 +99,10 @@ func getGoodFreshness(w http.ResponseWriter, r *http.Request){ http.Error(w, "the good was not found in database", http.StatusNotFound) return } - - fresh := good.FouledAt.Before(time.Now().Add(-time.Duration(3) * time.Hour * 24)) + fresh := false + if good.FouledAt != nil { + fresh = time.Now().Add(-time.Duration(3) * time.Hour * 24).Before(*good.FouledAt) + } log = log.WithField("type", r.Header.Get("Content-Type")) switch r.Header.Get("Content-Type") { diff --git a/webroot/index.html b/webroot/index.html index 747e3a6..96f9523 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -27,8 +27,13 @@ + +