Created
February 4, 2015 09:40
-
-
Save bigpresh/16eb155a7bee68014c24 to your computer and use it in GitHub Desktop.
Test case for utrack's JSON-PUTting Dancer2 problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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