0.0
No commit activity in last 3 years
No release in over 3 years
Provide referable routing mechanism for your Grape API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.10
~> 10.0
>= 0
 Project Readme

Grape::Routes

Allow you to refer to your Grape API routes as a function call.

class UseAPI < Grape::API
  prefix 'v1'
  format :json
  version 'v1', using: :header, vendor: 'myapi'

  resources :user do
    desc "create user"
    params do
      optional :fullname, type: String
    end
    post :create do
      # your code
    end
  end
end

You can refer to your API path as follow:

Grape::Routes.v1_user_create_post_path

You can refer to list of all available routes:

Grape::Routes.all_routes.keys

You can re-parse, only if you add routes on the fly, probably?

Grape::Routes.parse!

Installation

Add this line to your application's Gemfile:

gem 'grape_routes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install grape_routes

License

The gem is proudly available as open source under the terms of the MIT License.