mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
32 lines
585 B
Go
32 lines
585 B
Go
package handlers
|
|
|
|
import (
|
|
"log/slog"
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type PingHandler struct {
|
|
logger *slog.Logger
|
|
}
|
|
|
|
func NewPingHandler(log *slog.Logger) *PingHandler {
|
|
return &PingHandler{logger: log.With(slog.String("handler", "ping"))}
|
|
}
|
|
|
|
func (h *PingHandler) Register(e *echo.Echo) {
|
|
e.GET("/ping", h.Ping)
|
|
e.HEAD("/health", h.PingHead)
|
|
}
|
|
|
|
func (h *PingHandler) Ping(c echo.Context) error {
|
|
return c.JSON(http.StatusOK, map[string]string{
|
|
"status": "ok",
|
|
})
|
|
}
|
|
|
|
func (h *PingHandler) PingHead(c echo.Context) error {
|
|
return c.NoContent(http.StatusOK)
|
|
}
|