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:
@@ -13,13 +13,13 @@ initialize it in main()
|
||||
*/
|
||||
func (app *application) healthcheckHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Create a map which holds the information that we want to send in the response.
|
||||
data := map[string]string{
|
||||
env := envelope{
|
||||
"status": "available",
|
||||
"environment": app.config.env,
|
||||
"version": version,
|
||||
}
|
||||
|
||||
err := app.writeJSON(w, http.StatusOK, data, nil)
|
||||
err := app.writeJSON(w, http.StatusOK, env, 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