line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer2::Session::YAML; |
2
|
|
|
|
|
|
|
$Dancer2::Session::YAML::VERSION = '0.400001'; |
3
|
|
|
|
|
|
|
# ABSTRACT: YAML-file-based session backend for Dancer2 |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
2513
|
use Moo; |
|
4
|
|
|
|
|
6723
|
|
|
4
|
|
|
|
|
30
|
|
6
|
4
|
|
|
4
|
|
2725
|
use Dancer2::Core::Types; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
40
|
|
7
|
4
|
|
|
4
|
|
51865
|
use YAML; |
|
4
|
|
|
|
|
19264
|
|
|
4
|
|
|
|
|
732
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has _suffix => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => Str, |
12
|
|
|
|
|
|
|
default => sub {'.yml'}, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Dancer2::Core::Role::SessionFactory::File'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _freeze_to_handle { |
18
|
21
|
|
|
21
|
|
60
|
my ( $self, $fh, $data ) = @_; |
19
|
21
|
|
|
|
|
41
|
print {$fh} YAML::Dump($data); |
|
21
|
|
|
|
|
87
|
|
20
|
21
|
|
|
|
|
60756
|
return; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _thaw_from_handle { |
24
|
16
|
|
|
16
|
|
51
|
my ( $self, $fh ) = @_; |
25
|
16
|
|
|
|
|
38
|
local $YAML::LoadBlessed = 1; |
26
|
16
|
|
|
|
|
64
|
return YAML::LoadFile($fh); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=encoding UTF-8 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Dancer2::Session::YAML - YAML-file-based session backend for Dancer2 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 VERSION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
version 0.400001 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This module implements a session engine based on YAML files. Session are stored |
48
|
|
|
|
|
|
|
in a I<session_dir> as YAML files. The idea behind this module was to provide a |
49
|
|
|
|
|
|
|
human-readable session storage for the developer. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This backend is intended to be used in development environments, when digging |
52
|
|
|
|
|
|
|
inside a session can be useful. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This backend can perfectly be used in production environments, but two things |
55
|
|
|
|
|
|
|
should be kept in mind: The content of the session files is in plain text, and |
56
|
|
|
|
|
|
|
the session files should be purged by a CRON job. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 CONFIGURATION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The setting B<session> should be set to C<YAML> in order to use this session |
61
|
|
|
|
|
|
|
engine in a Dancer2 application. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Files will be stored to the value of the setting C<session_dir>, whose default |
64
|
|
|
|
|
|
|
value is C<appdir/sessions>. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Here is an example configuration that use this session engine and stores session |
67
|
|
|
|
|
|
|
files in /tmp/dancer-sessions |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
session: "YAML" |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
engines: |
72
|
|
|
|
|
|
|
session: |
73
|
|
|
|
|
|
|
YAML: |
74
|
|
|
|
|
|
|
session_dir: "/tmp/dancer-sessions" |
75
|
|
|
|
|
|
|
cookie_duration: 3600 # Default cookie timeout in seconds |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DEPENDENCY |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This module depends on L<YAML>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
See L<Dancer2::Core::Session> for details about session usage in route handlers. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Dancer Core Developers |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Alexis Sukrieh. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |