| 1 | package Clustericious::Controller; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 45 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 45 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 45 | ▶ | use Clustericious::Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 45 | ▶ | use Clustericious::Log; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 45 | ▶ | use Carp qw( carp ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 45 | ▶ | use base 'Mojolicious::Controller'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # ABSTRACT: Clustericious controller base class | ||||||||||||||||||||||||||||
| 11 | 45 | our $VERSION = '1.29'; # VERSION | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | sub url_for { | ||||||||||||||||||||||||||
|
Subroutine
url_for: called CC=4 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 4 | 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 | 4 | ▶ | return $_[0] if @_==1 && ref($_[0]) eq "Mojo::URL"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "Mojo::URL"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "Mojo::URL"
@_ == 1
ref $_[0] eq "Mojo::URL"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "Mojo::URL"
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 4 | my $base = $c->config->url_base( default => '' ); | |||||||||||||||||||||||||||
| 28 | 4 | my $url = $c->SUPER::url_for(@_); | |||||||||||||||||||||||||||
| 29 | 4 | ▶ | return $url unless $base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $url->base->parse($base); | |||||||||||||||||||||||||||
| 31 | 0 | return $url; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub redirect_to { | ||||||||||||||||||||||||||
|
Subroutine
redirect_to: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 0 | 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 | ▶ | if (my $url_base = Clustericious::Config->new(ref $self->app)->url_base(default => '')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | 45 | 1; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||