greenlight/cmd/api/healthcheck.go

24 lines
508 B
Go

package main
import (
"net/http"
)
func (app *application) healthCheckHandler(w http.ResponseWriter, r *http.Request) {
envelopedHealth := envelope{
"status": "available",
"system_info": map[string]string{
"environment": app.config.env,
"version": version,
},
}
err := app.writeJSON(w, http.StatusOK, envelopedHealth, nil)
if err != nil {
app.logger.Print(err)
http.Error(w, "the server encountered an error and could process your request", http.StatusInternalServerError)
}
}