ruby-grape / ruby-grape/grape

Dynamic matching / static matching - expected behaviour

Open
#1,858 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

chore feature request you can help
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.