@@ -5,7 +5,7 @@ import { onErrorHandler, ErrorHandler } from './onError.ts'
5
5
import rg from 'https://esm.sh/regexparam'
6
6
import { Request , getRouteFromApp } from './request.ts'
7
7
import { Response } from './response.ts'
8
- import { getURLParams , getPathname } from './parseUrl.ts'
8
+ import { getURLParams , getPathname } from './utils/ parseUrl.ts'
9
9
import { extendMiddleware } from './extend.ts'
10
10
import { serve , Server } from 'https://deno.land/std/http/server.ts'
11
11
import * as path from 'https://deno.land/std/path/mod.ts'
@@ -83,7 +83,7 @@ export class App<
83
83
locals : Record < string , string > = { }
84
84
noMatchHandler : Handler
85
85
onError : ErrorHandler
86
- settings : AppSettings
86
+ settings : AppSettings & Record < string , any >
87
87
engines : Record < string , TemplateFunc < RenderOptions > > = { }
88
88
applyExtensions ?: ( req : Req , res : Res , next : NextFunction ) => void
89
89
@@ -102,6 +102,18 @@ export class App<
102
102
this . applyExtensions = options ?. applyExtensions
103
103
}
104
104
105
+ set ( setting : string , value : any ) {
106
+ this . settings [ setting ] = value
107
+ }
108
+
109
+ enable ( setting : string ) {
110
+ this . settings [ setting ] = true
111
+ }
112
+
113
+ disable ( setting : string ) {
114
+ this . settings [ setting ] = false
115
+ }
116
+
105
117
/**
106
118
* Register a template engine with extension
107
119
*/
@@ -153,15 +165,11 @@ export class App<
153
165
use ( ...args : UseMethodParams < Req , Res , App > ) {
154
166
const base = args [ 0 ]
155
167
156
- const fns : any [ ] = args . slice ( 1 )
168
+ const fns : any [ ] = args . slice ( 1 ) . flat ( )
157
169
158
170
if ( base === '/' ) {
159
171
for ( const fn of fns ) {
160
- if ( Array . isArray ( fn ) ) {
161
- super . use ( base , fn )
162
- } else {
163
- super . use ( base , fns )
164
- }
172
+ super . use ( base , fn )
165
173
}
166
174
} else if ( typeof base === 'function' || base instanceof App ) {
167
175
super . use ( '/' , [ base , ...fns ] )
0 commit comments