use Moose;
+use namespace::clean -except => 'meta';
+
with 'MooseX::Emulate::Class::Accessor::Fast';
has action => (is => 'rw');
lazy => 1,
);
-# Moose TODO:
-# - Can we lose the before modifiers which just call prepare_body ?
-# they are wasteful, slow us down and feel cluttery.
-# Can we call prepare_body at BUILD time?
-# Can we make _body an attribute, have the rest of
-# these lazy build from there and kill all the direct hash access
-# in Catalyst.pm and Engine.pm?
-
has _context => (
is => 'rw',
weak_ref => 1,
default => sub { {} },
);
-before body_parameters => sub {
- my ($self) = @_;
- $self->_context->prepare_body();
-};
-
has uploads => (
is => 'rw',
required => 1,
default => sub { {} },
);
-before parameters => sub {
- my ($self, $params) = @_;
- if ( $params && !ref $params ) {
- $self->_context->log->warn(
- "Attempt to retrieve '$params' with req->params(), " .
- "you probably meant to call req->param('$params')" );
- $params = undef;
- }
+# TODO:
+# - Can we lose the before modifiers which just call prepare_body ?
+# they are wasteful, slow us down and feel cluttery.
+
+# Can we make _body an attribute, have the rest of
+# these lazy build from there and kill all the direct hash access
+# in Catalyst.pm and Engine.pm?
+before $_ => sub {
+ my ($self) = @_;
+ my $context = $self->_context || return;
+ $context->prepare_body;
+} for qw/parameters body_parameters/;
+
+around parameters => sub {
+ my ($orig, $self, $params) = @_;
+ if ($params) {
+ if ( !ref $params ) {
+ $self->_context->log->warn(
+ "Attempt to retrieve '$params' with req->params(), " .
+ "you probably meant to call req->param('$params')"
+ );
+ $params = undef;
+ }
+ return $self->$orig($params);
+ }
+ $self->$orig();
};
has base => (
has _path => ( is => 'rw', predicate => '_has_path', clearer => '_clear_path' );
-no Moose;
-
sub args { shift->arguments(@_) }
sub body_params { shift->body_parameters(@_) }
sub input { shift->body(@_) }
and the URI for the request was C<http://.../foo/moose/bah>, the string C<bah>
would be the first and only argument.
+Arguments just get passed through and B<don't> get unescaped automatically, so
+you should do that explicitly.
+
=head2 $req->args
Shortcut for arguments.
=head2 $req->base
-Contains the URI base. This will always have a trailing slash.
+Contains the URI base. This will always have a trailing slash. Note that the
+URI scheme (eg., http vs. https) must be determined through heuristics;
+depending on your server configuration, it may be incorrect. See $req->secure
+for more info.
If your application was queried with the URI
C<http://localhost:3000/some/path> then C<base> is C<http://localhost:3000/>.
=head2 $req->secure
-Returns true or false, indicating whether the connection is secure (https).
+Returns true or false, indicating whether the connection is secure
+(https). Note that the URI scheme (eg., http vs. https) must be determined
+through heuristics, and therefore the reliablity of $req->secure will depend
+on your server configuration. If you are serving secure pages on the standard
+SSL port (443) and/or setting the HTTPS environment variable, $req->secure
+should be valid.
=head2 $req->captures