|
|
@ -52,7 +52,7 @@ type (
|
|
|
|
jwtEnabled bool
|
|
|
|
jwtEnabled bool
|
|
|
|
signatureEnabled bool
|
|
|
|
signatureEnabled bool
|
|
|
|
authName string
|
|
|
|
authName string
|
|
|
|
middleware []string
|
|
|
|
middlewares []string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
route struct {
|
|
|
|
route struct {
|
|
|
|
method string
|
|
|
|
method string
|
|
|
@ -92,9 +92,9 @@ func genRoutes(dir string, api *spec.ApiSpec, force bool) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var routes string
|
|
|
|
var routes string
|
|
|
|
if len(g.middleware) > 0 {
|
|
|
|
if len(g.middlewares) > 0 {
|
|
|
|
gbuilder.WriteString("\n}...,")
|
|
|
|
gbuilder.WriteString("\n}...,")
|
|
|
|
var params = g.middleware
|
|
|
|
var params = g.middlewares
|
|
|
|
for i := range params {
|
|
|
|
for i := range params {
|
|
|
|
params[i] = "serverCtx." + params[i]
|
|
|
|
params[i] = "serverCtx." + params[i]
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -143,8 +143,9 @@ func genRoutes(dir string, api *spec.ApiSpec, force bool) error {
|
|
|
|
"routesAdditions": strings.TrimSpace(builder.String()),
|
|
|
|
"routesAdditions": strings.TrimSpace(builder.String()),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
formatCode := formatCode(buffer.String())
|
|
|
|
formatCode := formatCode(buffer.String())
|
|
|
|
_, err = fp.WriteString(formatCode)
|
|
|
|
_, err = fp.WriteString(formatCode)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -206,7 +207,7 @@ func getRoutes(api *spec.ApiSpec) ([]group, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if value, ok := apiutil.GetAnnotationValue(g.Annotations, "server", "middleware"); ok {
|
|
|
|
if value, ok := apiutil.GetAnnotationValue(g.Annotations, "server", "middleware"); ok {
|
|
|
|
for _, item := range strings.Split(value, ",") {
|
|
|
|
for _, item := range strings.Split(value, ",") {
|
|
|
|
groupedRoutes.middleware = append(groupedRoutes.middleware, item)
|
|
|
|
groupedRoutes.middlewares = append(groupedRoutes.middlewares, item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
routes = append(routes, groupedRoutes)
|
|
|
|
routes = append(routes, groupedRoutes)
|
|
|
|