You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
900 B
Smarty
33 lines
900 B
Smarty
package {{.PkgName}}
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
|
|
{{if .HasRequest}}"github.com/zeromicro/go-zero/rest/httpx"{{end}}
|
|
|
|
{{.ImportPackages}}
|
|
)
|
|
|
|
{{.HandlerDoc}}
|
|
|
|
func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
{{if .TransErr}}const transErr = true{{else}}const transErr = false{{end}}
|
|
{{if .HasRequest}}var req types.{{.RequestType}}
|
|
if err := httpx.Parse(r, &req); err != nil {
|
|
statusz.ResponseHandler(r, w, transErr, nil, err)
|
|
return
|
|
}
|
|
|
|
{{end}}
|
|
l := {{.LogicName}}.New{{.LogicType}}(r, r.Context(), svcCtx)
|
|
{{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}})
|
|
{{if .HasResp}}
|
|
statusz.ResponseHandler(r, w, transErr, resp, err)
|
|
{{else}}
|
|
statusz.ResponseHandler(r, w, transErr, nil, err)
|
|
{{end}}
|
|
}
|
|
}
|