Skip to content

Add helpers for getting current endpoint #5

Description

@hobofan

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions