Document superhero storing and improve API response message
This commit is contained in:
@@ -146,7 +146,13 @@ func (r *Router) StoreSuperHero(w http.ResponseWriter, req *http.Request) {
|
||||
// Return JSON
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
_, err = w.Write([]byte(`{"status": "ok"}`))
|
||||
|
||||
// Response body
|
||||
_, err = w.Write([]byte(`{
|
||||
"message": "Superhero stored successfully.",
|
||||
"status": "success"
|
||||
}`))
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user