File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,10 @@ export const createDynamicHandler =
295295 let response = hook . fn ( context )
296296
297297 if ( hook . subType === 'resolve' ) {
298+ if ( response instanceof ElysiaCustomStatusResponse ) {
299+ const result = mapEarlyResponse ( response , context . set )
300+ if ( result ) return ( context . response = result )
301+ }
298302 if ( response instanceof Promise )
299303 Object . assign ( context , await response )
300304 else Object . assign ( context , response )
Original file line number Diff line number Diff line change @@ -210,14 +210,19 @@ describe('resolve', () => {
210210 } )
211211
212212 it ( 'handle error' , async ( ) => {
213- const app = new Elysia ( )
213+ const route = new Elysia ( )
214214 . resolve ( ( ) => {
215215 return error ( 418 )
216216 } )
217217 . get ( '/' , ( ) => '' )
218218
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" )
220226
221- expect ( res ) . toEqual ( "I'm a teapot" )
222227 } )
223228} )
You can’t perform that action at this time.
0 commit comments