pushbits/internal/api/health.go
2021-01-16 16:56:49 +01:00

22 lines
444 B
Go

package api
import (
"net/http"
"github.com/gin-gonic/gin"
)
// HealthHandler holds information for processing requests about the server's health.
type HealthHandler struct {
DB Database
}
// Health returns the health status of the server.
func (h *HealthHandler) Health(ctx *gin.Context) {
if err := h.DB.Health(); err != nil {
ctx.AbortWithError(http.StatusInternalServerError, err)
return
}
ctx.JSON(http.StatusOK, gin.H{})
}