Skip to content

Support distinguishing method mismatches from path misses for proper 405 responses #177

Closed

Description

@coderabbitai

Problem

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.

References

Proposed Solution

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

  1. added
    area: routing
    bug
    on Sep 18, 2025
  2. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Sep 18, 2025
  3. moved this from In Progress 🔥 to Done 🚀 in Serverpod Frameworkson Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: routingbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions