X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FRequest.pm;h=fe05db7ea12dfeee914b679adbb968765cd73595;hb=219b019151f23cf468dc1a08b64da92234abe92d;hp=ee2bee75e8dc7170bf061e181309fddb102d4daf;hpb=2ef2fb0f3a712ba1239a5fed7e332ced3bbe663f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index ee2bee7..fe05db7 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -117,6 +117,34 @@ Shortcut to $req->headers->content_length Shortcut to $req->headers->content_type +=item $req->cookie + +A convenient method to $req->cookies. + + $cookie = $c->request->cookie('name'); + @cookies = $c->request->cookie; + +=cut + +sub cookie { + my $self = shift; + + if ( @_ == 0 ) { + return keys %{ $self->cookie }; + } + + if ( @_ == 1 ) { + + my $name = shift; + + unless ( exists $self->cookie->{$name} ) { + return undef; + } + + return $self->cookie->{$name}; + } +} + =item $req->cookies Returns a reference to a hash containing the cookies. @@ -161,8 +189,8 @@ Shortcut for $req->body. =item $req->match -This contains be the matching part of a regexp action. Otherwise it -returns the same as 'action'. +This contains the matching part of a regexp action. Otherwise +it returns the same as 'action'. print $c->request->match;