NAME

Async::MicroserviceReq - async microservice request class

SYNOPSYS

my $this_req  = Async::MicroserviceReq->new(
    method     => $plack_req->method,
    headers    => $plack_req->headers,
    content    => $plack_req->content,
    path       => $plack_req->path_info,
    params     => $plack_req->parameters,
    static_dir => $self->static_dir,
);

...

my $plack_handler_sub = sub {
    my ($plack_respond) = @_;
    $this_req->plack_respond($plack_respond);
...

DESCRIPTION

This is an object created for each request handled by Async::Microservice. It is passed to all request handling functions as first argument and it provides some request info and response helper methods.

ATTRIBUTES

method
headers
path
params
plack_respond
static_dir
base_url
want_json
content
json_content

METHODS

text_plain(@text_lines)

Send text plain response.

respond($status, $headers, $payload)

Send plack response.

redirect($location_path)

Send redirect.

static($file_name, $content_cb)

Send static file, can be updated/modified using optional callback.

get_pending_req

Returns number of currently pending async requests.