Mojolicious-Plugin-Args

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/Args.pm  view on Meta::CPAN

             ( $c->req->method eq 'GET' and defined $stash->{format} and $stash->{format} eq 'json' and defined $args{json} ) ) {
            my @args = keys %args;
            my $json = decode_json( $c->req->method eq 'GET' ? delete $args{json} : $c->req->body );
            my @json = keys %{ $json };
            do {
                $args{__args}->{ $_ } = $args{ $_ }   for @args; # save to __priv
                $args{__json}->{ $_ } = $json->{ $_ } for @json; # for specific access
            } if $want_detail;
            $args{ $_ } = $json->{ $_ } for @json;
        }
        %args = ( %args, %save ); # this allows interception and override from route conditions that want to validate/modify and/or hooks
        $stash->{args} = \%args;
        return wantarray ? %{ $stash->{args} } : $stash->{args};
    } ) unless $app->renderer->helpers->{args};
}

# ABSTRACT: gives you back the request parameters as a simple %args hash, even if it's posted in json.
1;

__END__



( run in 1.188 second using v1.01-cache-2.11-cpan-39bf76dae61 )