-
Notifications
You must be signed in to change notification settings - Fork 3
Routes inside constraints block don't respect format constraints #94
Copy link
Copy link
Open
Description
Problem
When wrapping standard_resources in a constraints format: :json block, the format constraint is not enforced. Requests without a .json extension (e.g. GET /transactions) still match the route and hit the controller, resulting in a StandardAPI::ParameterMissing error because required params like limit are missing.
# Expected: /transactions should NOT match, /transactions.json should match
constraints format: :json do
standard_resources :transactions
endWorkaround
Using a lambda constraint works:
constraints(->(req) { req.format.json? }) do
standard_resources :transactions
endExpected Behavior
constraints format: :json should restrict standard_resources routes to only match when the format segment is json, consistent with how resources behaves when wrapped in the same block.
Context
This matters for SPAs where bare paths like /transactions should fall through to a catch-all route serving the frontend, while /transactions.json should hit the API controller.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels