|
|
@ -23,6 +23,7 @@ var handlerTemplate string
|
|
|
|
type handlerInfo struct {
|
|
|
|
type handlerInfo struct {
|
|
|
|
PkgName string
|
|
|
|
PkgName string
|
|
|
|
ImportPackages string
|
|
|
|
ImportPackages string
|
|
|
|
|
|
|
|
ImportHttpxPackage string
|
|
|
|
HandlerName string
|
|
|
|
HandlerName string
|
|
|
|
RequestType string
|
|
|
|
RequestType string
|
|
|
|
LogicName string
|
|
|
|
LogicName string
|
|
|
@ -49,6 +50,7 @@ func genHandler(dir, rootPkg string, cfg *config.Config, group spec.Group, route
|
|
|
|
return doGenToFile(dir, handler, cfg, group, route, handlerInfo{
|
|
|
|
return doGenToFile(dir, handler, cfg, group, route, handlerInfo{
|
|
|
|
PkgName: pkgName,
|
|
|
|
PkgName: pkgName,
|
|
|
|
ImportPackages: genHandlerImports(group, route, parentPkg),
|
|
|
|
ImportPackages: genHandlerImports(group, route, parentPkg),
|
|
|
|
|
|
|
|
ImportHttpxPackage: fmt.Sprintf("\"%s/rest/httpx\"", vars.ProjectOpenSourceURL),
|
|
|
|
HandlerName: handler,
|
|
|
|
HandlerName: handler,
|
|
|
|
RequestType: util.Title(route.RequestTypeName()),
|
|
|
|
RequestType: util.Title(route.RequestTypeName()),
|
|
|
|
LogicName: logicName,
|
|
|
|
LogicName: logicName,
|
|
|
@ -99,7 +101,6 @@ func genHandlerImports(group spec.Group, route spec.Route, parentPkg string) str
|
|
|
|
if len(route.RequestTypeName()) > 0 {
|
|
|
|
if len(route.RequestTypeName()) > 0 {
|
|
|
|
imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir)))
|
|
|
|
imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
imports = append(imports, fmt.Sprintf("\"%s/rest/httpx\"", vars.ProjectOpenSourceURL))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return strings.Join(imports, "\n\t")
|
|
|
|
return strings.Join(imports, "\n\t")
|
|
|
|
}
|
|
|
|
}
|
|
|
|