line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
$Kelp::Module::Raisin::VERSION = '1.01'; |
2
|
|
|
|
|
|
|
use Kelp::Base qw(Kelp::Module::Symbiosis::Base); |
3
|
2
|
|
|
2
|
|
73605
|
use Plack::Util; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
2387
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
5
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
398
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
1
|
162
|
# since Raisin::API is really a singleton we have to keep it that way. If we |
8
|
|
|
|
|
|
|
# wouldn't, test suite would be full of Raisin route redefinition warnings and |
9
|
|
|
|
|
|
|
# would likely lead to buggy code |
10
|
|
|
|
|
|
|
my $psgi; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
{ |
13
|
|
|
|
|
|
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
return $psgi //= $self->app->raisin->run; |
16
|
5
|
|
|
5
|
1
|
43021
|
} |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
66
|
|
|
21
|
{ |
19
|
|
|
|
|
|
|
my ($self, %args) = @_; |
20
|
|
|
|
|
|
|
$self->SUPER::build(%args); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
die 'Raisin module requires "class" configuration' |
23
|
5
|
|
|
5
|
1
|
9387
|
unless $args{class}; |
24
|
5
|
|
|
|
|
23
|
|
25
|
|
|
|
|
|
|
my $class = Plack::Util::load_class($args{class}); |
26
|
|
|
|
|
|
|
|
27
|
5
|
100
|
|
|
|
31
|
# let it bug out with regular error message if it can't app |
28
|
|
|
|
|
|
|
my $raisin = $class->app; |
29
|
4
|
|
|
|
|
10
|
die "$class not isa Raisin" |
30
|
|
|
|
|
|
|
unless defined blessed $raisin && $raisin->isa('Raisin'); |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
1149
|
$self->register(raisin => $raisin); |
33
|
2
|
100
|
66
|
|
|
53
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
1
|
|
|
|
|
7
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Kelp::Module::Raisin - Raisin integration with Kelp |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# in config - order matters |
44
|
|
|
|
|
|
|
modules => [qw(Symbiosis Raisin)], |
45
|
|
|
|
|
|
|
modules_init => { |
46
|
|
|
|
|
|
|
# optional |
47
|
|
|
|
|
|
|
Symbiosis => { |
48
|
|
|
|
|
|
|
mount => '/path', # will mount Kelp under /path |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# required |
52
|
|
|
|
|
|
|
Raisin => { |
53
|
|
|
|
|
|
|
mount => '/api', # will mount Raisin under /api |
54
|
|
|
|
|
|
|
class => 'My::Raisin', # required - full class name of Raisin app |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# in application's build method |
59
|
|
|
|
|
|
|
$self->raisin->add_route( |
60
|
|
|
|
|
|
|
method => 'GET', |
61
|
|
|
|
|
|
|
path => '/from-kelp', |
62
|
|
|
|
|
|
|
params => {}, |
63
|
|
|
|
|
|
|
code => sub { 'Hello World from Kelp, in Raisin!' }, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# in psgi script |
67
|
|
|
|
|
|
|
$app = MyKelpApp->new; |
68
|
|
|
|
|
|
|
$app->run_all; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is a very straightforward module that integrates the L<Kelp> framework with the L<Raisin> API framework using L<Kelp::Module::Symbiosis>. See the documentation for L<Kelp::Module::Symbiosis> and L<Kelp::Module::Symbiosis::Base> for a full reference on how this module behaves. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 MODULE INFORMATION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This module name is I<'raisin'>. You can refer to it with that name in Symbiosis methods - I<loaded> and I<mounted>. There shouldn't be a need to, since it will be mounted automatically if you specify L</mount> in configuration. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
The module class itself does not expose anything particularly interesting, it is just a wrapper for Raisin. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS INTRODUCED TO KELP |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 raisin |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $raisin = $kelp->raisin; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns the running instance of Raisin. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 CONFIGURATION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 middleware, middleware_init |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Same as L<Kelp::Module::Symbiosis::Base/middleware, middleware_init>. Since Raisin can wrap itself in its own middleware it will likely not be that useful. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 mount |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See L<Kelp::Module::Symbiosis::Base/mount> for details. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 class |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Should be a full name of the package that defines an api using L<Raisin::API>. Keep in mind that Raisin::API is really a singleton so it is not suitable for multiple app setup. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 2 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * L<Kelp>, the framework |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * L<Raisin>, the API framework |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Bartosz Jarzyna, E<lt>bbrtj.pro@gmail.comE<gt> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Copyright (C) 2020 - 2022 by Bartosz Jarzyna |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
122
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|