in reply to How to get the Catalyst Context object

My current solution is setting a global variable in my root controller... but I'd prefer to use the "official" way and to be compatible with any Catalyst App without changing it.

site:catalystframework.org context -> Application-wide access to the context ($c) for the impatient .. stuff $c in a localized global ... Caveats

package MyApp; use Catalyst; our $__ACTIVE_CTX = undef; sub ctx { $__ACTIVE_CTX } around 'dispatch' => sub { my ($orig, $c, @args) = @_; local $__ACTIVE_CTX = $c; $c->$orig(@args) };