Dynamic matching / static matching - expected behaviour
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
When trying to have an endpoint that matches dynamically except for specific keywords.
i.e.
GET resource/:id => returns the resource
GET resource/new => returns a JSON schema of the resource
The issue is that when I define it this way:
class ResourceAPI
get 'resource/:id' do
# ...
end
get 'resource/new' do
# ...
end
end
I will never hit the resource/new endpoint. However, if I define it the other way around, it will work.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the route definitions shown in the issue and inspect Grape's endpoint matching and declaration-order behavior. Confirm whether a static resource/new route can take precedence over resource/:id regardless of definition order; done means both routes resolve to their intended handlers, with regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100