[Catalyst] hostname

Knut-Olav Hoven hovenko at linpro.no
Fri Jan 11 09:31:26 GMT 2008


On Thursday 10 January 2008 21:15:25 Octavian Rasnita wrote:
> From: "Ash Berlin" <ash_cpan at firemirror.com>
>
> > How did you get to a function in MyApp.pm during a request....
> >
> > # in MyApp.pm
> >
> > sub foobarbaz {
> >    my ($c) = @_;
> > }
> >
> > # In controller code.
> > $c->foobarbaz();
> >
> > Make sense?
>
> Not really.
>
> I've tried (in MyApp.pm):
>
> sub the_host {
> my ($c) = @_;
> return $c->req->hostname;
> }
>
> and then I've tried to use
>
> cookie_domain => the_host()
> in the MyApp config, but when I try to start the server it gives an error
> telling that I can't use the method "req" because $c is undefined.

You could use MyApp::Root::auto to lookup the hostname from the request and 
set it in config as you wish.

Example:

# MyApp::Root;
sub auto : Private {
  my ( $self, $c ) = @_;
  $c->config->{cookie_domain} = $c->req->hostname;
}

>
> But anyway, what I need is working because I can avoid setting a domain
> name for the cookie.
>
> Octavian
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



-- 
Knut-Olav Hoven
Systemutvikler               mob: +47 986 71 700
Linpro AS                    http://www.linpro.no/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080111/549d5e0f/attachment.pgp


More information about the Catalyst mailing list