本页还没有译文
本页 5 段还没译成한국어,下面显示的是英文原文。Middleware
还没翻译译自英文(hono.dev)本页 5 段都还没译
Middleware
We call the primitive that returns Response as "Handler".
"Middleware" is executed before and after the Handler and handles the Request and Response.
It's like an onion structure.

For example, we can write the middleware to add the "X-Response-Time" header as follows.
app.use(async (c, next) => {
const start = performance.now()
await next()
const end = performance.now()
c.res.headers.set('X-Response-Time', `${end - start}`)
})With this simple method, we can write our own custom middleware and we can use the built-in or third party middleware.
AI 翻译查看英文原文