BitWeaverDev 641abb68da feat(engine): add SkipMethodNotAllowedMiddleware option
Middleware registered via Use() is prepended to the NoMethod handlers by
rebuild405Handlers, so a global middleware that aborts the request answers
before the NoMethod handler can reply. A middleware validating a header that
only some methods carry therefore turns every 405 into its own error
response.

Add an opt-in Engine.SkipMethodNotAllowedMiddleware flag that runs only the
NoMethod handlers for 405 responses. It is disabled by default, so existing
behaviour is unchanged.

The flag is resolved when the request is served rather than when the chain is
built, so it applies regardless of the order in which Use(), NoMethod() and
the flag are set. Requests handled by NoRoute() keep running the global
middleware.

Fixes #4189
2026-08-19 21:25:12 +02:00
..