package ping

import (
	"net/http"

	"backend/internal/logic/ping"
	"backend/internal/svc"

	"github.com/zeromicro/go-zero/rest/httpx"
)

// PingHandler 系統健康檢查
func PingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		l := ping.NewPingLogic(r.Context(), svcCtx)
		err := l.Ping()
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.Ok(w)
		}
	}
}
