[Catalyst] ActionClass('RenderView') questions

Tomas Doran bobtfish at bobtfish.net
Tue Mar 5 03:00:43 GMT 2013

On 4 Mar 2013, at 22:59, E R <pc88mxer at gmail.com> wrote:

> In my root controller, I have this method:
> sub end : ActionClass('RenderView') { ... }
> I understand that this method is called after the controller for the request has finished and just before the view is called to render any output.
> My question is: in this 'end' method, how can I determine what the response status is going to be (i.e. 200, 302, etc.),

As you will have set that already, so you can just call $c->res->status to retrieve it.

> and if the response is a redirect how can I get at the redirection location?

Again, you'll have set it already - i.e. it'll be retrievable from $c->res->headers if you need it.

What's the use-case here? Generally for a 200 you need to render a template, and for a 302 you don't want to (as there is no body), and the RenderView action class handles these default cases automagically.

This (generally) means that you don't need to get these values back - why do you think you need to / what are you trying to achieve?

> Also, what does it mean if $c->stash->{template} is undef at this point?

Maybe :)

You can explicitly set this, or you can let it default (in _some_ views) - it depends on your app.


More information about the Catalyst mailing list