Browse Source

Close #9

master
kreativmonkey 5 years ago
parent
commit
715ff0e216
  1. 8
      api.go

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

Loading…
Cancel
Save