grape-route-helpers icon indicating copy to clipboard operation
grape-route-helpers copied to clipboard

Add helpers for getting current endpoint

Open hobofan opened this issue 10 years ago • 1 comments

It would be nice if there would be a helper for getting the path of the current endpoint, like:

class ExampleAPI < Grape::API
  version 'v1'
  prefix 'api'
  format 'json'

  resource :cats do
    get '/' do
      current_path # returns the same thing as api_v1_cats_path
    end
  end

  resource :dogs do
    get '/' do
      current_path # returns the same thing as api_v1_dogs_path
    end
  end
end

My use case would be constructing pagination links. For that I always need to get the path of the current endpoint being used and add some query parameters to it.

hobofan avatar Oct 01 '15 10:10 hobofan

That does sound useful, I'll put it in the next release and ping you when it's out. Thank you for your feedback!

reprah avatar Oct 08 '15 15:10 reprah