Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Output routes in "rake routes" look and feel #3

Open
dennisvdvliet opened this issue Jun 10, 2016 · 2 comments
Open

Feature: Output routes in "rake routes" look and feel #3

dennisvdvliet opened this issue Jun 10, 2016 · 2 comments

Comments

@dennisvdvliet
Copy link
Contributor

dennisvdvliet commented Jun 10, 2016

Something this:

routes = Alligator::V1.apiculture_stack.select{|d| d.is_a? Apiculture::ActionDefinition}
prefix = Alligator::V1.instance_variable_get(:@apiculture_mounted_at)
format = "%7s %-75s %-50s\n"
routes.each do |route|
  printf format % [route.http_verb.upcase, prefix + route.path, route.description]
end

But a little less hacky

@julik
Copy link
Contributor

julik commented Jun 12, 2016

Maybe MyApp.action_routes.each { ... }?

@julik
Copy link
Contributor

julik commented Jun 18, 2016

Why don't we piggyback on the Sinatra way of doing it? Like here: http://stackoverflow.com/questions/13694058/how-to-get-a-list-of-all-routes-used-in-a-sinatra-app

This way we can first get all the routes of the app, and maybe print route definitions from Apiculture as well if they intersect. We can also overload Sinatra::Base#routes and augment the stuff returned from it with Apicluture metadata if it is available for a specific route. And printing the routes will then be handled externally in any way the user sees fit. Yay?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants