server/unmatched_route.ts

What a request no route answers gets: the assembled server's not-found handler, twin of the Rust spine's method fallback (fuz_http::compose_stack) and fallback group (fuz_actions::server::unmatched_route_response).

  • A method its path doesn't serve — the path matches a route under another method — is 405 {"error":"method_not_allowed"} with Allow naming the methods the path serves, HEAD wherever GET is.
  • A path no route serves is 404: under the auth scope (AUTH_MIDDLEWARE_PATH) the JSON {"error":"route_not_found"}, like every other refusal there; elsewhere the one plain-text NOT_FOUND_TEXT. A route that passed the request on (the WebSocket path's GET asking for no upgrade) answers the same.

The methods a path serves are read from the app's own router — every route registered on it, a spec's, a WebSocket upgrade's or one a consumer adds to the assembled app, and never a middleware (ALL).

Both decide on the raw path the router matched (get_request_path), so /%61pi/x is outside the auth scope, as on the Rust spine. Hono runs this after every middleware, so the host gate and the origin check answer first, and ahead of authentication, which only the routes enforce: an anonymous PUT on the RPC path is the 405, not a 401. The answer is built through the context, so the session middleware's clear of a cookie that doesn't verify rides it like any other.

view source

Declarations
#

2 declarations

create_unmatched_route_handler
#

server/unmatched_route.ts view source

(router: UnmatchedRouteRouter): NotFoundHandler import {create_unmatched_route_handler} from '@fuzdev/fuz_app/server/unmatched_route.js';

Build the not-found handler (module doc) over the app's router.

router

the assembled app's router, app.router, read at request time, so a route added after assembly is seen too

returns

NotFoundHandler

the handler for app.notFound

UnmatchedRouteRouter
#

Depends on
#

Imported by
#