NAME
Pono::Request - The request in a Pono handler
SYNOPSIS
$app->post('/posts/:id' => sub {
my ($c) = @_;
my $id = $c->req->param('id');
my $page = $c->req->query('page');
my $type = $c->req->header('Content-Type');
my $data = $c->req->json;
...
});
METHODS
param
my $id = $c->req->param('id');
my $all = $c->req->param;
Returns a path parameter. Without a name, returns all of them as a hash reference. The part matched by * has the name *. Values are decoded as UTF-8.
query
my $q = $c->req->query('q');
my $all = $c->req->query;
Returns a query string parameter. Without a name, returns all of them as a hash reference. Values are decoded as UTF-8.
header
my $agent = $c->req->header('User-Agent');
Returns a request header. The name is case insensitive.
method
Returns the HTTP method.
path
Returns the request path.
url
Returns the full URL of the request.
body
Returns the request body as bytes.
text
Returns the request body as a string, decoded as UTF-8.
json
Returns the request body parsed as JSON. Dies if the body is not valid JSON.
parse_body
my $form = $c->req->parse_body;
my $name = $form->{name};
Returns the fields of an application/x-www-form-urlencoded body as a hash reference.
env
Returns the PSGI environment.
SEE ALSO
LICENSE
Copyright (C) Yusuke Wada.
This library is free software; you can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE file in this distribution.