Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Base URI breakdown

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


trevor.phillips at gmail

Mar 6, 2009, 7:02 PM

Post #1 of 4 (1017 views)
Permalink
Base URI breakdown

In a Catalyst app, I need to break down the base request URL to
extract hostname, port, etc separately.

I could do this with a regexp on $c->request->base, or I could use the
URI perl lib, but is there already a way to access this within
Catalyst?

The docs say that $c->request->base is a string only, whereas I'd like
to access separately bits like $c->request->base->host and
$c->request->base->port.

--
Trevor Phillips - http://dortamur.livejournal.com/
"On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole."
-- (Terry Pratchett, Wyrd Sisters)

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


brian.cassidy at gmail

Mar 6, 2009, 7:08 PM

Post #2 of 4 (929 views)
Permalink
Re: Base URI breakdown [In reply to]

On Fri, Mar 6, 2009 at 11:02 PM, Trevor Phillips
<trevor.phillips [at] gmail> wrote:
> In a Catalyst app, I need to break down the base request URL to
> extract hostname, port, etc separately.

Could you not use $c->req->uri [1]?

-Brian

[1] http://search.cpan.org/dist/Catalyst-Runtime/lib/Catalyst/Request.pm#$req-%3Euri

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


arodland at comcast

Mar 6, 2009, 7:25 PM

Post #3 of 4 (926 views)
Permalink
Re: Base URI breakdown [In reply to]

On Friday 06 March 2009 09:02:01 pm Trevor Phillips wrote:
> In a Catalyst app, I need to break down the base request URL to
> extract hostname, port, etc separately.
>
> I could do this with a regexp on $c->request->base, or I could use the
> URI perl lib, but is there already a way to access this within
> Catalyst?
>
> The docs say that $c->request->base is a string only, whereas I'd like
> to access separately bits like $c->request->base->host and
> $c->request->base->port.

$c->req->base is a URI object under all of the Engine types that I'm aware of.
The docs don't promise this, but they don't say it's not either. Anyway
there's no reason you couldn't do URI->new($c->req->base) which will be a
perfectly good URI object whether base is a URI or an unblessed string. :)

Andrew

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


trevor.phillips at gmail

Mar 6, 2009, 9:38 PM

Post #4 of 4 (932 views)
Permalink
Re: Base URI breakdown [In reply to]

On Sat, Mar 7, 2009 at 12:25 PM, Andrew Rodland <arodland [at] comcast> wrote:
>
> $c->req->base is a URI object under all of the Engine types that I'm aware of.

Next time I should just try things before assuming the docs are absolute. ^_^

> The docs don't promise this, but they don't say it's not either. Anyway
> there's no reason you couldn't do URI->new($c->req->base) which will be a
> perfectly good URI object whether base is a URI or an unblessed string. :)

Sounds good to me. Thanks!

--
Trevor Phillips - http://dortamur.livejournal.com/
"On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole."
-- (Terry Pratchett, Wyrd Sisters)

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.