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 @@ -295,6 +295,10 @@ export const createDynamicHandler =
295
295
let response = hook . fn ( context )
296
296
297
297
if ( hook . subType === 'resolve' ) {
298
+ if ( response instanceof ElysiaCustomStatusResponse ) {
299
+ const result = mapEarlyResponse ( response , context . set )
300
+ if ( result ) return ( context . response = result )
301
+ }
298
302
if ( response instanceof Promise )
299
303
Object . assign ( context , await response )
300
304
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