Commit a775aa99 authored by Aksel Baardsen's avatar Aksel Baardsen
Browse files

application returns json

parent 0b188342
......@@ -16,7 +16,9 @@ func Chandler(w http.ResponseWriter, r *http.Request) {
}
country, code := pkg.GetCountryByCode(vars["country_identifier"], limit)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
c, _ := json.Marshal(country)
if code == 200 {
_, _ = fmt.Fprintln(w, string(c))
......
......@@ -11,6 +11,8 @@ func Dhandler(w http.ResponseWriter, r *http.Request) {
var d pkg.Diag
pkg.GetDiag(&d)
w.Header().Set("Content-Type", "application/json")
marsh, _ := json.Marshal(d)
_, _ = fmt.Fprintln(w, string(marsh))
}
......
......@@ -12,6 +12,7 @@ func Shandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
specie, code := pkg.GetSpecies(vars["speciesKey"])
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
s, _ := json.Marshal(specie)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment