package handler import ( "net/http" "github.com/zeromicro/x/errors" "demo/internal/logic" "demo/internal/svc" "github.com/zeromicro/go-zero/rest/httpx" ) func Test503Handler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { l := logic.NewTest503Logic(r.Context(), svcCtx) resp, err := l.Test503() if err != nil { // httpx.ErrorCtx(r.Context(), w, err) httpx.WriteJson(w, http.StatusServiceUnavailable, errors.New(503, "503")) } else { httpx.OkJsonCtx(r.Context(), w, resp) } } }