Skip to content

Commit

Permalink
Idiot-proof the links I just sent
Browse files Browse the repository at this point in the history
  • Loading branch information
thijzert committed Apr 25, 2017
1 parent 8c97705 commit 4084bba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/journal-server/journal-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ func TieHandler(w http.ResponseWriter, r *http.Request) {
date = time.Now().AddDate(0, 0, 2)
} else if vars["date"] == "yesterday" {
date = time.Now().AddDate(0, 0, -1)
} else if vars["date"] == "yyyy-mm-dd" || vars["date"] == "jjjj-mm-dd" {
w.Header()["Content-Type"] = []string{"text/plain"}
w.WriteHeader(400)
w.Write([]byte("Don't be a smartarse."))
return
} else {
var err error
date, err = time.Parse("2006-01-02", vars["date"])
Expand All @@ -245,6 +250,7 @@ func TieHandler(w http.ResponseWriter, r *http.Request) {
w.Header()["Content-Type"] = []string{"text/plain"}
w.WriteHeader(404)
w.Write([]byte("No tie was found for that day.\n\nLive a little; wear a t-shirt.\n"))
return
}
}

Expand Down

0 comments on commit 4084bba

Please sign in to comment.