Skip to content
Myr

Builtin Middleware!

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

authored by Yusuke Wada · committed by Yusuke Wada · parent 53418f9 · Browse files · 7 files+72 added−7 removed
This commit

State

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

Diff stats

7 files+72 added−7 removed

  • tests:+34 added−0 removed
  • other:+38 added−7 removed

7 files+72 added−7 removed

modified:example/basic/index.js+6 added-3 removed
added:src/middleware/poweredBy.js+6 added
added:src/middleware/poweredBy.test.js+17 added
modified:src/hono.d.ts+6 added-1 removed
modified:src/middleware.js+5 added-1 removed
added:src/middleware.test.js+17 added
modified:README.md+15 added-2 removed
100 unmodified lines
101```102103## Middleware104105### Builtin Middleware106107```js108const { Hono, Middleware } = require('hono')109110...111112app.use('*', Middleware.poweredBy)113114```115116### Custom Middleware117118```js119const logger = (c, next) => {120 console.log(`[${c.req.method}] ${c.req.url}`)121 next()122}
2 unmodified lines
125 next()126 c.res.headers.add('x-message', 'This is middleware!')127}128116app = app.use('*', logger)117app = app.use('/message/*', addHeader)129app.use('*', logger)130app.use('/message/*', addHeader)131132app.get('/message/hello', () => 'Hello Middleware!')133```134
56 unmodified lines