@@ -228,39 +228,34 @@ func JWTSecurity(name string, fn ...func()) *expr.SchemeExpr {
228
228
// })
229
229
func Security (args ... any ) {
230
230
var dsl func ()
231
- {
232
- if d , ok := args [len (args )- 1 ].(func ()); ok {
233
- args = args [:len (args )- 1 ]
234
- dsl = d
235
- }
236
- }
237
-
238
- var schemes []* expr.SchemeExpr
239
- {
240
- schemes = make ([]* expr.SchemeExpr , len (args ))
241
- for i , arg := range args {
242
- switch val := arg .(type ) {
243
- case string :
244
- for _ , s := range expr .Root .Schemes {
245
- if s .SchemeName == val {
246
- schemes [i ] = expr .DupScheme (s )
247
- break
248
- }
249
- }
250
- if schemes [i ] == nil {
251
- eval .ReportError ("security scheme %q not found" , val )
252
- return
253
- }
254
- case * expr.SchemeExpr :
255
- if val == nil {
256
- eval .InvalidArgError ("security scheme" , val )
257
- return
231
+ if d , ok := args [len (args )- 1 ].(func ()); ok {
232
+ args = args [:len (args )- 1 ]
233
+ dsl = d
234
+ }
235
+
236
+ schemes := make ([]* expr.SchemeExpr , len (args ))
237
+ for i , arg := range args {
238
+ switch val := arg .(type ) {
239
+ case string :
240
+ for _ , s := range expr .Root .Schemes {
241
+ if s .SchemeName == val {
242
+ schemes [i ] = expr .DupScheme (s )
243
+ break
258
244
}
259
- schemes [i ] = expr .DupScheme (val )
260
- default :
261
- eval .InvalidArgError ("security scheme or security scheme name" , val )
245
+ }
246
+ if schemes [i ] == nil {
247
+ eval .ReportError ("security scheme %q not found" , val )
248
+ return
249
+ }
250
+ case * expr.SchemeExpr :
251
+ if val == nil {
252
+ eval .InvalidArgError ("security scheme" , val )
262
253
return
263
254
}
255
+ schemes [i ] = expr .DupScheme (val )
256
+ default :
257
+ eval .InvalidArgError ("security scheme or security scheme name" , val )
258
+ return
264
259
}
265
260
}
266
261
0 commit comments