api add middleware support (#140)
* rebase upstream
* rebase
* trim no need line
* trim no need line
* trim no need line
* update doc
* remove update
* remove no need
* remove no need
* goctl add jwt support
* goctl add jwt support
* goctl add jwt support
* goctl support import
* goctl support import
* support return ()
* revert
* refactor and rename folder to group
* remove no need
* add anonymous annotation
* optimized
* rename
* rename
* update test
* api add middleware support: usage:
@server(
middleware: M1, M2
)
* api add middleware support: usage:
@server(
middleware: M1, M2
)
* simple logic
* should reverse middlewares
* optimized
* optimized
* rename
Co-authored-by: kingxt <dream4kingxt@163.com>
This commit is contained in:
@@ -66,6 +66,18 @@ func getAuths(api *spec.ApiSpec) []string {
|
||||
return authNames.KeysStr()
|
||||
}
|
||||
|
||||
func getMiddleware(api *spec.ApiSpec) []string {
|
||||
result := collection.NewSet()
|
||||
for _, g := range api.Service.Groups {
|
||||
if value, ok := util.GetAnnotationValue(g.Annotations, "server", "middleware"); ok {
|
||||
for _, item := range strings.Split(value, ",") {
|
||||
result.Add(strings.TrimSpace(item))
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.KeysStr()
|
||||
}
|
||||
|
||||
func formatCode(code string) string {
|
||||
ret, err := goformat.Source([]byte(code))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user