|
|
@ -57,6 +57,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error {
|
|
|
|
if !ok {
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("missing handler annotation for %q", route.Path)
|
|
|
|
return fmt.Errorf("missing handler annotation for %q", route.Path)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handler = strings.TrimSuffix(handler, "handler")
|
|
|
|
handler = strings.TrimSuffix(handler, "handler")
|
|
|
|
handler = strings.TrimSuffix(handler, "Handler")
|
|
|
|
handler = strings.TrimSuffix(handler, "Handler")
|
|
|
|
filename := strings.ToLower(handler)
|
|
|
|
filename := strings.ToLower(handler)
|
|
|
@ -65,6 +66,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !created {
|
|
|
|
if !created {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -74,11 +76,11 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
imports := genLogicImports(route, parentPkg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
responseString := ""
|
|
|
|
imports := genLogicImports(route, parentPkg)
|
|
|
|
returnString := ""
|
|
|
|
var responseString string
|
|
|
|
requestString := ""
|
|
|
|
var returnString string
|
|
|
|
|
|
|
|
var requestString string
|
|
|
|
if len(route.ResponseType.Name) > 0 {
|
|
|
|
if len(route.ResponseType.Name) > 0 {
|
|
|
|
resp := strings.Title(route.ResponseType.Name)
|
|
|
|
resp := strings.Title(route.ResponseType.Name)
|
|
|
|
responseString = "(*types." + resp + ", error)"
|
|
|
|
responseString = "(*types." + resp + ", error)"
|
|
|
@ -104,6 +106,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
formatCode := formatCode(buffer.String())
|
|
|
|
formatCode := formatCode(buffer.String())
|
|
|
|
_, err = fp.WriteString(formatCode)
|
|
|
|
_, err = fp.WriteString(formatCode)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|