Skip to content

Instantly share code, notes, and snippets.

@bigpresh
Created February 4, 2015 09:40
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 bigpresh/16eb155a7bee68014c24 to your computer and use it in GitHub Desktop.
Save bigpresh/16eb155a7bee68014c24 to your computer and use it in GitHub Desktop.
Test case for utrack's JSON-PUTting Dancer2 problem
#!/usr/bin/perl
#
use lib '/home/davidp/dev/github/Dancer2/lib';
use Dancer2;
set serializer => 'Mutable';
put '/put' => sub {
warn "request body: " . request->body;
warn "hi: " . params->{hi};
};
dance;
#!/usr/bin/perl
use strict;
use JSON;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(
PUT => 'http://localhost:3000/put',
[ 'Content-Type' => 'application/json' ],
JSON::to_json({ hi => 'json' }),
);
my $res = $ua->request($req);
die "Got result: " . $res->status_line;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment