add go fiber example
This commit is contained in:
19
go-fiber-simple/cmd/api/healthcheck.go
Normal file
19
go-fiber-simple/cmd/api/healthcheck.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user