mirror of
https://github.com/pushbits/server.git
synced 2025-06-06 12:41:59 +02:00
Add health check for Docker image
This commit is contained in:
parent
3bdadd6029
commit
da1aa3c3b8
5 changed files with 37 additions and 0 deletions
22
api/health.go
Normal file
22
api/health.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
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{})
|
||||
}
|
|
@ -6,6 +6,8 @@ import (
|
|||
|
||||
// The Database interface for encapsulating database access.
|
||||
type Database interface {
|
||||
Health() error
|
||||
|
||||
CreateApplication(application *model.Application) error
|
||||
DeleteApplication(application *model.Application) error
|
||||
GetApplicationByID(ID uint) (*model.Application, error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue