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. data := map[string]string{ "status": "available", "environment": app.config.env, "version": version, } err := app.writeJSON(w, http.StatusOK, data, 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) } }