master
kreativmonkey 8 years ago
parent fb4deaf057
commit 715ff0e216

@ -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)
}

Loading…
Cancel
Save