Within a Padrino application I have a posts controller with the conventional routes:
Blog::App.controllers :posts do
get :index do
...
end
get :show, :with => :id do
...
end
end
This gives me therefore the normal URL access within the posts namespace
http://blog.dev/posts
http://blog.dev/posts/show/1
Now I want to provide access through a REST API from a different route outside the namespace, like for example:
http://blog.dev/api/v1/post/all
http://blog.dev/api/v1/post/1
How can I define the API for my posts controller with routes outside its normal namespace?
I must admit that I am not sure if my approach is the common one. I could define a new API V1 controller but in that case, I will have to duplicate information about posts in two different places.
In case this should be done with an API controller, I wonder which gems and/or conventions are commonly use for this task. Ideally I would like something that coordinates different API versions with the current model object.