package main import ( "net/http" ) /* Tips: The important thing to point out here is that healthcheckHandler is implemented as a method on our application struct. This is an effective and idiomatic way to make dependencies available to our handlers without resorting to global variables or closures - any dependency that the healthcheckHandler needs can simply be included as a field in the application struct when we 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. env := envelope{ "status": "available", "environment": app.config.env, "version": version, } err := app.writeJSON(w, http.StatusOK, env, nil) if err != nil { // Use the new serverErrorResponse() helper app.serverErrorResponse(w, r, err) } }