Hono middleware
The onion order
Middleware is an async (c, next) => { ... } function registered with app.use. Code before await next() runs on the way in and code after it runs on the way out, so two middleware and a handler log a-in, b-in, the handler, b-out, a-out. Middleware registered on * also wraps requests that match no route, which is why a header set after next() can appear on a 404.
Guards and scoped middleware
Returning a response without calling next() ends the request there, and the handler never runs. The lesson’s sign-in check works this way: a missing or unknown user header gets a 401 and leaves nothing in the trace. A path pattern such as app.use('/admin/*', ...) keeps the middleware off public routes. The Hono middleware guide lists the built-in middleware; these exercises write their own, so each step is visible.