32 lines
725 B
Go
32 lines
725 B
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.9.1
|
|
|
|
package ping
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/JACKYMYPERSON/hldrCenter/config"
|
|
"github.com/JACKYMYPERSON/hldrCenter/internal/logic/ping"
|
|
"github.com/JACKYMYPERSON/hldrCenter/internal/types"
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
|
)
|
|
|
|
func PingHandler(cfg *config.Config) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req types.PingReq
|
|
if err := httpx.Parse(r, &req); err != nil {
|
|
httpx.ErrorCtx(r.Context(), w, err)
|
|
return
|
|
}
|
|
|
|
l := ping.NewPingLogic(r.Context(), cfg)
|
|
resp, err := l.Ping(&req)
|
|
if err != nil {
|
|
httpx.ErrorCtx(r.Context(), w, err)
|
|
} else {
|
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
|
}
|
|
}
|
|
}
|