Skip to content

Commit

Permalink
Item14033: More JSON Request work
Browse files Browse the repository at this point in the history
 - create some rudimentary unit tests based up on the Rest tests.
 - add path_info as an aliase for pathInfo
  • Loading branch information
gac410 committed May 12, 2016
1 parent 9710bc2 commit 2f37e8d
Show file tree
Hide file tree
Showing 3 changed files with 720 additions and 1 deletion.
Expand Up @@ -218,7 +218,6 @@ sub dispatch {
sub getHandler {
my ( $this, $request ) = @_;

print STDERR "getHandler called\n";
my $namespace = $request->namespace();
return unless $namespace;

Expand Down
14 changes: 14 additions & 0 deletions JsonRpcContrib/lib/Foswiki/Request/JSON.pm
Expand Up @@ -66,9 +66,14 @@ optional method from the path. eg: bin/jsonrpc/SomeNamespace/themethod
=cut

*path_info = \&pathInfo;

sub pathInfo {
my ( $this, $pathInfo ) = @_;

print STDERR " pathInfo entered " . Data::Dumper::Dumper( \$pathInfo )
if Foswiki::Request::TRACE;

return $_[0]->SUPER::pathInfo() if @_ == 1;

my $decodedInfo = Foswiki::urlDecode($pathInfo);
Expand Down Expand Up @@ -147,6 +152,9 @@ Call SUPER::method() to access the http method.
sub method {
my ( $this, $value ) = @_;

print STDERR "method entered " . Data::Dumper::Dumper( \$value )
if Foswiki::Request::TRACE;

if ( defined $value && !defined $this->{_jsondata} && lc($value) ne 'post' )
{
$this->{_jsonerror} =
Expand Down Expand Up @@ -229,6 +237,9 @@ Initializes the {_jsondata} hash by processing the POSTDATA from the request.
sub initFromString {
my ( $this, $data ) = @_;

print STDERR "initFromString\n$data\n"
if Foswiki::Request::TRACE;

# parse json-rpc request
eval { $this->{_jsondata} = $this->json->decode($data); };

Expand Down Expand Up @@ -339,6 +350,9 @@ can both read and write.
sub jsonmethod {
my ( $this, $value ) = @_;

print STDERR "jsonmethod entered " . Data::Dumper::Dumper( \$value )
if Foswiki::Request::TRACE;

$this->{_jsondata}{method} = $value if defined $value;
return $this->{_jsondata}{method};
}
Expand Down

0 comments on commit 2f37e8d

Please sign in to comment.