NAME

Plack::Middleware::RequestId - generate the request id

SYNOPSIS

enable 'RequestId';

options

enable 'RequestId',
    http_header => 'X-Request-Id';

use another id generator if you want

enable 'RequestId',
    id_generator => sub {
        Digest::MD5::md5_hex($$, time(), $env->{PATH_INFO})
    };

See MIDDLEWARE OPTIONS for other options.

DESCRIPTION

Plack::Middleware::RequestId generates the request id and sets it into HTTP header.

MIDDLEWARE OPTIONS

psgi_env_key

The key string for storing an ID in PSGI environment variables. default: psgix.request_id

http_header

The key string for an ID in HTTP Headers. default: X-Request-Id

no_http_header

If this option was set true value then the request id does not put in HTTP Headers.

id_generator

The code ref for generating an ID. By default, using Data::UUID.

force_generate_id

If you set true value to this oprion, then the ID always generates every request no matter what there is X-Request-Id header.

env_key

If you would like to store request id in %ENV also, set a key strings to this option.

Getting ID TIPS

Normally, you get the request ID from PSGI env. However, the ID has been stored $Plack::Middleware::RequestId::request_id also. So you can get it anywhere.

METHODS

prepare_app
call

REPOSITORY

Plack::Middleware::RequestId is hosted on github: http://github.com/bayashi/Plack-Middleware-RequestId

I appreciate any feedback :D

AUTHOR

Dai Okabayashi <bayashi@cpan.org>

SEE ALSO

Rack::RequestId https://github.com/anveo/rack-request-id

Data::UUID

Plack::Middleware

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.