feat: Create collection file for routes
This commit is contained in:
24
server/route.go
Normal file
24
server/route.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (api *ApiServer) HealthCheckRoute(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
response := HealthCheckResponse{
|
||||
Database: api.DatabaseConnection.Ping(),
|
||||
API: true,
|
||||
Status: "OK",
|
||||
}
|
||||
err := json.NewEncoder(w).Encode(response)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_, err := w.Write([]byte("Internal Server Error"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user