Files
examples/go-fiber-simple/cmd/api/healthcheck.go

20 lines
453 B
Go
Raw Normal View History

2024-06-30 20:14:30 -06:00
package main
import (
"net/http"
)
func (app *application) healthcheckHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]string{
"status": "ok",
"version": version,
}
// No need to add acess control origin headers. On other routes, that may be necessary
err := app.writeJSON(w, http.StatusOK, data, nil)
if err != nil {
app.logger.Error(err.Error())
http.Error(w, "server error", http.StatusInternalServerError)
}
}