d;
use JSON::PP ();
use Regexp::Common;
use Scalar::Util ();
# use Crypt::JWT;
# 2019-09-26
# We use our own drop-in replacement because of a bug in ModPerl and JSON::XS not re
# Response content type
$r->content_type( 'application/json' );
my $json = JSON->new->relaxed->utf8;
$self->{json} = $json;
# No need to go further if the ip address is not al
$rdef->{message} }) );
}
# Net::API::REST::reply will automatically set a json with an error message based on the user language
else
{
r
# use JSON::MaybeXS qw(decode_json encode_json);
# JSON::XS does not play well with ModPerl, so luckily we can use the Pure Perl version
use JSON::PP qw( decode_json encode_json );
us
d in json, decoding first.\n" ) if( $args{debug} );
my $hash = decode_json( $args{token} );
if( $hash->{payload} && $hash->{protected} )
{
# Flattened JWS JSON Ser
elsif( $hash->{ciphertext} && $hash->{protected} )
{
# Flattened JWE JSON Serialization
( $header, $payload ) = _decode_jwe( $hash->{protected}, $hash->{encryp
NAL_SERVER_ERROR );
$r->rflush;
# $r->send_http_header;
$r->print( $self->json->encode({ 'error' => 'An unexpected server error occured', 'code' => 500 }) );
$self->err
NAL_SERVER_ERROR );
$r->rflush;
# $r->send_http_header;
$r->print( $self->json->encode({ 'error' => 'An unexpected server error occured', 'code' => 500 }) );
$self->err
ch
local $@;
my $json = eval
{
$self->json->encode( $ref );
};
if( $@ )
{
$self->error( "An error occurred while encoding data into JSON: $@" );
return(
s://api.example.com/users/123/payment_method/456
with an http Accept field value of: application/json; charset=utf-8; version=1
If no api version is specified either way, then the latest one provide
q is not an hash reference
my $q = $self->request->params;
# or maybe the user sent you a json payload?
$q = $self->request->payload if( !scalar( keys( %$q ) ) && $self->request->payload );