You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support distinguishing method mismatches from path misses for proper 405 responses #177
Currently, the Router class in relic does not distinguish between path misses and method mismatches. Both scenarios result in no match, which makes it impossible for downstream applications to return proper HTTP 405 Method Not Allowed responses when a path matches a route but the HTTP method is not supported.
Expected Behavior
The routing system should provide a way to distinguish between:
Path miss: No route matches the requested path (should result in 404 Not Found)
Method mismatch: A route matches the path but not the HTTP method (should result in 405 Method Not Allowed with Allow header)
Use Case
This is needed to implement proper HTTP semantics in web servers built with relic. When a client requests a valid path with an unsupported method, the server should respond with:
HTTP status 405 Method Not Allowed
Allow header containing comma-separated list of supported methods for that path
Appropriate response body
Current Implementation Impact
Without this distinction, applications using relic fall back to 404 responses for method mismatches, which violates HTTP semantics and provides poor developer experience.
Consider enhancing the Router class or routeWith function to return additional information that allows callers to distinguish between these cases, such as:
A result type that indicates the type of mismatch
Separate handling for method vs path mismatches
Additional metadata about available methods for matched paths
Activity