Skip to content

Instantly share code, notes, and snippets.

@hesco
Created February 8, 2018 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hesco/5a6d53874224036a82a0258c922f20f7 to your computer and use it in GitHub Desktop.
Save hesco/5a6d53874224036a82a0258c922f20f7 to your computer and use it in GitHub Desktop.
$ grep 'do/' lib/MyAPI.pm
$auth->get('/aup/latest_version_signed/do/:action/*aup_component')->to('acceptable_use_policy#action_signed');
$auth->get('/aup/latest_version/do/:action/*aup_component')->to('acceptable_use_policy#action');
----
[Wed Feb 7 23:37:50 2018] [debug] GET "/v1/app/aup/latest_version_signed/do/copy/foo/bar.txt"
[Wed Feb 7 23:37:50 2018] [debug] Routing to controller "MyAPI::Controller::UserSessions" and action "logged_in"
[Wed Feb 7 23:37:50 2018] [debug] Routing to controller "MyAPI::Controller::AcceptableUsePolicy" and action "copy"
[Wed Feb 7 23:37:51 2018] [info] ->copy says: action: |copy| -- aup_component: |foo/bar.txt| -- git_path: |aup| -- component_version: |0.1.0-4-gb04e439|
[Wed Feb 7 23:37:51 2018] [debug] 200 OK (0.826711s, 1.210/s)
----
and a dump of the json returned shows a latest_version key,
provided by the #action path, rather than the latest_version_signed key,
populated by the #action_signed path.
----
sub action {
my $self = shift;
my $action = $self->stash('action');
my $aup_component = $self->stash('aup_component');
my $logger = $self->app->log;
$logger->info("->action says: action: $action -- aup_component: $aup_component");
if( length( $aup_component ) ){
if( length( $action ) ){
$self->$action;
}
}
}
sub action_signed {
my $self = shift;
my $action = $self->stash('action');
my $userid = $self->session('userid');
my $aup_component = $self->stash('aup_component');
my $logger = $self->app->log;
$logger->info("->action_signed says: action: $action -- userid: $userid -- aup_component: $aup_component");
if( length( $aup_component ) ){
if( length( $action ) ){
my $method = "${action}_signed";
$self->${method};
}
}
}
sub copy {
my $self = shift;
<snip>
return $self->render( json => {copy => $copy, latest_version => $component_version, aup_component => $aup_component } );
}
sub copy_signed {
my $self = shift;
<snip>
return $self->render( json => {copy => $copy, latest_version_signed => $component_version, aup_component => $aup_component } );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment