Plack::Middleware::RequestId - generate the request id
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.
MIDDLEWARE OPTIONS
Plack::Middleware::RequestId generates the request id and sets it into HTTP header.
The key string for storing an ID in PSGI environment variables. default: psgix.request_id
psgix.request_id
The key string for an ID in HTTP Headers. default: X-Request-Id
X-Request-Id
If this option was set true value then the request id does not put in HTTP Headers.
The code ref for generating an ID. By default, using Data::UUID.
If you set true value to this oprion, then the ID always generates every request no matter what there is X-Request-Id header.
If you would like to store request id in %ENV also, set a key strings to this option.
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.
$Plack::Middleware::RequestId::request_id
Plack::Middleware::RequestId is hosted on github: http://github.com/bayashi/Plack-Middleware-RequestId
I appreciate any feedback :D
Dai Okabayashi <bayashi@cpan.org>
Rack::RequestId https://github.com/anveo/rack-request-id
Data::UUID
Plack::Middleware
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Plack::Middleware::RequestId, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::RequestId
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::RequestId
For more information on module installation, please visit the detailed CPAN module installation guide.