File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,10 @@ export const createDynamicHandler =
294
294
let response = hook . fn ( context )
295
295
296
296
if ( hook . subType === 'resolve' ) {
297
+ if ( response instanceof ElysiaCustomStatusResponse ) {
298
+ const result = mapEarlyResponse ( response , context . set )
299
+ if ( result ) return ( context . response = result )
300
+ }
297
301
if ( response instanceof Promise )
298
302
Object . assign ( context , await response )
299
303
else Object . assign ( context , response )
Original file line number Diff line number Diff line change @@ -210,14 +210,19 @@ describe('resolve', () => {
210
210
} )
211
211
212
212
it ( 'handle error' , async ( ) => {
213
- const app = new Elysia ( )
213
+ const route = new Elysia ( )
214
214
. resolve ( ( ) => {
215
215
return error ( 418 )
216
216
} )
217
217
. get ( '/' , ( ) => '' )
218
218
219
- const res = await app . handle ( req ( '/' ) ) . then ( ( x ) => x . text ( ) )
219
+ const res = await ( new Elysia ( { aot : true } ) ) . use ( route ) . handle ( req ( '/' ) )
220
+ expect ( await res . status ) . toEqual ( 418 )
221
+ expect ( await res . text ( ) ) . toEqual ( "I'm a teapot" )
222
+
223
+ const res2 = await ( new Elysia ( { aot : false } ) ) . use ( route ) . handle ( req ( '/' ) )
224
+ expect ( await res2 . status ) . toEqual ( 418 )
225
+ expect ( await res2 . text ( ) ) . toEqual ( "I'm a teapot" )
220
226
221
- expect ( res ) . toEqual ( "I'm a teapot" )
222
227
} )
223
228
} )
You can’t perform that action at this time.
0 commit comments