27 lines
741 B
Smarty
27 lines
741 B
Smarty
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl {{.version}}
|
|
|
|
package {{.PkgName}}
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/zero-ppanel/zero-ppanel/pkg/result"
|
|
{{.ImportPackages}}
|
|
)
|
|
|
|
{{if .HasDoc}}{{.Doc}}{{end}}
|
|
func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
{{if .HasRequest}}var req types.{{.RequestType}}
|
|
if err := result.Parse(r, &req); err != nil {
|
|
result.HttpResult(r, w, nil, err)
|
|
return
|
|
}
|
|
|
|
{{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx)
|
|
{{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}})
|
|
{{if .HasResp}}result.HttpResult(r, w, resp, err){{else}}result.HttpResult(r, w, nil, err){{end}}
|
|
}
|
|
}
|