line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Clustericious::Controller; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
6601
|
use strict; |
|
24
|
|
|
|
|
59
|
|
|
24
|
|
|
|
|
639
|
|
4
|
24
|
|
|
24
|
|
123
|
use warnings; |
|
24
|
|
|
|
|
45
|
|
|
24
|
|
|
|
|
521
|
|
5
|
24
|
|
|
24
|
|
365
|
use Clustericious::Config; |
|
24
|
|
|
|
|
45
|
|
|
24
|
|
|
|
|
472
|
|
6
|
24
|
|
|
24
|
|
109
|
use Clustericious::Log; |
|
24
|
|
|
|
|
51
|
|
|
24
|
|
|
|
|
172
|
|
7
|
24
|
|
|
24
|
|
16855
|
use Carp qw( carp ); |
|
24
|
|
|
|
|
59
|
|
|
24
|
|
|
|
|
1099
|
|
8
|
24
|
|
|
24
|
|
143
|
use base 'Mojolicious::Controller'; |
|
24
|
|
|
|
|
55
|
|
|
24
|
|
|
|
|
7662
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Clustericious controller base class |
11
|
|
|
|
|
|
|
our $VERSION = '1.27'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub url_for { |
15
|
8
|
|
|
8
|
1
|
18
|
my $c = shift; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# NOTE: the only place it looks like we need to use this bizzarely |
18
|
|
|
|
|
|
|
# customized url_for is in Restmd. If we can confirm/deny that we |
19
|
|
|
|
|
|
|
# do/don't need it there, then we can probably remove this special case |
20
|
|
|
|
|
|
|
# NOTE2: also used in the function below. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Note: This dos not seem to be the case anymore: |
23
|
|
|
|
|
|
|
# Original Comment: link_to calls url_for on a Mojo::URL which for some reason |
24
|
|
|
|
|
|
|
# causes /a/b?c=d to not work properly (? is escaped) |
25
|
8
|
50
|
33
|
|
|
59
|
return $_[0] if @_==1 && ref($_[0]) eq "Mojo::URL"; |
26
|
|
|
|
|
|
|
|
27
|
8
|
|
|
|
|
112
|
my $base = $c->config->url_base( default => '' ); |
28
|
8
|
|
|
|
|
49
|
my $url = $c->SUPER::url_for(@_); |
29
|
8
|
100
|
|
|
|
2132
|
return $url unless $base; |
30
|
2
|
|
|
|
|
6
|
$url->base->parse($base); |
31
|
2
|
|
|
|
|
352
|
return $url; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub redirect_to { |
36
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Response |
39
|
0
|
|
|
|
|
|
my $res = $self->res; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Code |
42
|
0
|
|
|
|
|
|
$res->code(302); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Headers |
45
|
0
|
|
|
|
|
|
my $headers = $res->headers; |
46
|
0
|
|
|
|
|
|
my $loc = $self->url_for(@_); |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if (my $url_base = Clustericious::Config->new(ref $self->app)->url_base(default => '')) { |
49
|
0
|
|
|
|
|
|
$loc->base->parse($url_base); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$headers->location($loc->to_abs); |
53
|
0
|
|
|
|
|
|
$headers->content_length(0); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Rendered |
56
|
0
|
|
|
|
|
|
$self->rendered; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Clustericious::Controller - Clustericious controller base class |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 1.27 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SYNOPSIS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use base qw( Clustericious::Controller ); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Base class for all controllers in Clustericious applications |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SUPER CLASS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L<Mojolicious::Controller> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 METHODS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 url_for |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Clustericious version of this method usually provided by Mojolicious. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 redirect_to |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copied from Mojolicious::Controller, but works around |
98
|
|
|
|
|
|
|
a limitation of Apache's mod_proxy (namely: the ProxyPassReverse |
99
|
|
|
|
|
|
|
directive doesn't handle authorization information in the |
100
|
|
|
|
|
|
|
Location header.) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
It does this by explicitly using the url_base from the |
103
|
|
|
|
|
|
|
Clustericious config file for the app as the base for |
104
|
|
|
|
|
|
|
the location header. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<Clustericious> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Original author: Brian Duggan |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Current maintainer: Graham Ollis E<lt>plicease@cpan.orgE<gt> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Contributors: |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Curt Tilmes |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Yanick Champoux |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is copyright (c) 2013 by NASA GSFC. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
127
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |