Skip to content

Commit

Permalink
improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed May 8, 2022
1 parent cd4211a commit d0514e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion holidays-api/holidaysapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ func (h *Handler) responseHolidays(w http.ResponseWriter, holidays []holiday.Hol
func (h *Handler) responseNotFound(w http.ResponseWriter) {
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%d", 24*60*60))
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Link", "<https://github.com/sponsors/shogo82148>; rel=\"author\"")

// ref. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security#examples
w.Header().Set("Strict-Transport-Security", "max-age=63072000")

w.WriteHeader(http.StatusNotFound)
io.WriteString(w, `{"error":"not found"}`)
io.WriteString(w, `{"error":"not found","message":"see https://github.com/shogo82148/holidays-jp/ for more information."}`)
}

0 comments on commit d0514e6

Please sign in to comment.