Is there a way to internally redirect in Padrino? I am writing a RESTful service, no HTML response of browser client.
I have a resource, lets say, xyz
.
MyApp.controllers :xyz
I have two routes in a controller:
put :index, :with => :xyz_id do...end
and
get :show, :map => '/xyz/:xyz_id' do...end
Now to simplify (and centralize) view (which is a JSON document) creation, I want to just internally redirect the control so that it processes the :show
method after creating the resource. Hence, for a client of the service, PUT /xyz/1234
will create a new resource and return the same and GET /xyz/1234
will return the resource if it exists.
Is there a way to INTERNALLY (not a 302 response sent to the client) redirect to get :show
method from the put :index
method (after creating the resource)? Something like:
redirect (:xyz, :index, {:xyz_id => '1234'})