Skip to content
Myr

fix(combine/every): make `every` middleware work with short-circuiting middlewares (#3441)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Paweł Dąbrowski · committed by GitHub · parent ad0bba0 · Browse files · 2 files+17 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−0 removed

  • tests:+16 added−0 removed
  • other:+1 added−0 removed

2 files+17 added−0 removed

modified:src/middleware/combine/index.test.ts+16 added
148 unmodified lines
149150 expect(await res.text()).toBe('oops')151 expect(middleware2).not.toBeCalled()152 })153154 it('Should return the same response a middleware returns if it short-circuits the chain', async () => {155 const middleware1: MiddlewareHandler = async (c) => {156 return c.text('Hello Middleware 1')157 }158 const middleware2 = vi.fn(nextMiddleware)159160 app.use('/', every(middleware1, middleware2))161 app.get('/', (c) => {162 return c.text('Hello World')163 })164 const res = await app.request('http://localhost/')165166 expect(await res.text()).toBe('Hello Middleware 1')167 expect(middleware2).not.toBeCalled()168 })169})170171describe('except', () => {172 let app: Hono
108 unmodified lines
modified:src/middleware/combine/index.ts+1 added