From 715ff0e2169b6f84f467e88ec9210d1e353eade2 Mon Sep 17 00:00:00 2001 From: kreativmonkey Date: Sat, 1 Jul 2017 18:32:35 +0200 Subject: [PATCH] Close #9 --- api.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index 2ccccdb..93484f3 100644 --- a/api.go +++ b/api.go @@ -33,6 +33,7 @@ func APIshorten(w http.ResponseWriter, r *http.Request){ respond := response{ Action: "shorten", + Status: "200", Result: r.Host + "/" + token, } @@ -52,10 +53,10 @@ func APIlookup(w http.ResponseWriter, r *http.Request){ check(err) var result shrty.Data - var respond response if ok := short.Get(queryu, &result); ok { respond := response{ Action: "lookup", + Status: "200", Result: result, } @@ -67,6 +68,11 @@ func APIlookup(w http.ResponseWriter, r *http.Request){ } else { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusNotFound) + respond := response{ + Action: "lookup", + Status: "404", + Result: result, + } if err := json.NewEncoder(w).Encode(&respond); err != nil { panic(err) }