What is the feature you are proposing?
Currently, onError and notFound only accept a single handler. It would be great if they could accept middlewares, similar to route definitions.
Use Case: running specific middleware (e.g., languageDetector) when rendering 404 page or error page, without registering it globally.
(For example you might not want to use languageDetector globally because it has the side effect of disabling the edge cache due to the Set-Cookie.)
const app = new Hono()
app.notFound(
languageDetector(),
(c) => {
return c.html(render404Page(c.get("language")))
}
)
app.onError(
languageDetector(),
(err, c) => {
return c.html(renderErrorPage(c.get("language")))
}
)
What is the feature you are proposing?
Currently,
onErrorandnotFoundonly accept a single handler. It would be great if they could accept middlewares, similar to route definitions.Use Case: running specific middleware (e.g.,
languageDetector) when rendering 404 page or error page, without registering it globally.(For example you might not want to use
languageDetectorglobally because it has the side effect of disabling the edge cache due to theSet-Cookie.)