Unique identifier of the dancer's request

Is there a unique request identifier in Dancer?

Apache has mod_unique_id: http://httpd.apache.org/docs/current/mod/mod_unique_id.html

PSGI / Plack has a middleware module: http://search.cpan.org/~bayashi/Plack-Middleware-RequestId-0.02/lib/Plack/Middleware/RequestId.pm

But is there anything native to Dancer that I missed?

+4
source share
1 answer

When I need unique identifiers for use with Mojolicious, I used Data::UUIDone that generates long (128 bits) numbers in accordance with RFC 4122

, , , :

#!/usr/bin/env perl

use strict;
use warnings;

use Data::UUID;

my $gen = Data::UUID -> new();

my $binary_uuid = $gen -> create ;

print $gen -> to_string ( $binary_uuid ),"\n";
print $gen -> to_hexstring ( $binary_uuid ),"\n";
print $gen -> to_b64string ( $binary_uuid ),"\n";

. , , , :

my $gen = Data::UUID -> new();
my $uuid = $gen -> create_str ;
print $uuid, "\n";
#reformat output
print $gen -> to_hexstring ( $uuid ),"\n";
+1

All Articles