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.
24 lines
698 B
Smarty
24 lines
698 B
Smarty
2 years ago
|
package {{.PkgName}}
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"git.noahlan.cn/noahlan/ntools-go/zero/respz"
|
||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||
|
{{.ImportPackages}}
|
||
|
)
|
||
|
|
||
|
func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||
|
{{if .HasRequest}}var req types.{{.RequestType}}
|
||
|
if err := httpx.Parse(r, &req); err != nil {
|
||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
{{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx)
|
||
|
{{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}})
|
||
|
{{if .HasResp}}respz.ResponseHandler(r, w, resp, err){{else}}respz.ResponseHandler(r, w, nil, err){{end}}
|
||
|
}
|
||
|
}
|