grape-route-helpers
grape-route-helpers copied to clipboard
Add helpers for getting current endpoint
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.
That does sound useful, I'll put it in the next release and ping you when it's out. Thank you for your feedback!