clean up subs
This commit is contained in:
@@ -188,16 +188,20 @@ hook 'before_template' => sub {
|
|||||||
$Template::Stash::PRIVATE = undef;
|
$Template::Stash::PRIVATE = undef;
|
||||||
};
|
};
|
||||||
|
|
||||||
# remove empty lines from CSV response
|
# workaround for Swagger plugin weird response body
|
||||||
# this makes writing templates much more straightforward!
|
|
||||||
hook 'after' => sub {
|
hook 'after' => sub {
|
||||||
my $r = shift; # a Dancer::Response
|
my $r = shift; # a Dancer::Response
|
||||||
|
|
||||||
# workaround for Swagger plugin weird response body
|
|
||||||
if (request->path eq '/swagger.json') {
|
if (request->path eq '/swagger.json') {
|
||||||
$r->content( to_json( $r->content ) );
|
$r->content( to_json( $r->content ) );
|
||||||
header('Content-Type' => 'application/json');
|
header('Content-Type' => 'application/json');
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
# remove empty lines from CSV response
|
||||||
|
# this makes writing templates much more straightforward!
|
||||||
|
hook 'after' => sub {
|
||||||
|
my $r = shift; # a Dancer::Response
|
||||||
|
|
||||||
if ($r->content_type and $r->content_type eq 'text/comma-separated-values') {
|
if ($r->content_type and $r->content_type eq 'text/comma-separated-values') {
|
||||||
my @newlines = ();
|
my @newlines = ();
|
||||||
|
|||||||
@@ -59,8 +59,9 @@ hook 'before' => sub {
|
|||||||
};
|
};
|
||||||
|
|
||||||
get qr{^/(?:login(?:/denied)?)?} => sub {
|
get qr{^/(?:login(?:/denied)?)?} => sub {
|
||||||
|
# FIXME not sure this is the right approach
|
||||||
if (param('return_url') and param('return_url') =~ m{^/api/}) {
|
if (param('return_url') and param('return_url') =~ m{^/api/}) {
|
||||||
status 403;
|
status('unauthorized')
|
||||||
return to_json {
|
return to_json {
|
||||||
error => 'not authorized',
|
error => 'not authorized',
|
||||||
return_url => param('return_url'),
|
return_url => param('return_url'),
|
||||||
|
|||||||
Reference in New Issue
Block a user