Document superhero storing and improve API response message

This commit is contained in:
2023-02-07 04:53:44 +00:00
parent fca4c76cf9
commit 21fb147017
2 changed files with 33 additions and 4 deletions

View File

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