Creating an envelope struct type inside our helpers file to update our writeJSON data type method's parameter. Updating healthcheckHandler and showMovieHandler with this new type to update our responses.
This commit is contained in:
@@ -36,7 +36,7 @@ func (app *application) showMovieHandler(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
// Encode the struct to JSON and send it as the HTTP response.
|
||||
err = app.writeJSON(w, http.StatusOK, movie, nil)
|
||||
err = app.writeJSON(w, http.StatusOK, envelope{"movie": movie}, nil)
|
||||
if err != nil {
|
||||
app.logger.Error(err.Error())
|
||||
http.Error(w, "The server encountered a problem and could not process your request", http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user