Skip to content

Instantly share code, notes, and snippets.

@phillipadsmith
Last active August 29, 2015 14:04
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 phillipadsmith/cae2026965c2dcc513fe to your computer and use it in GitHub Desktop.
Save phillipadsmith/cae2026965c2dcc513fe to your computer and use it in GitHub Desktop.
Value of $self->req->json is undef
put '/source' => sub {
my $self = shift;
my $schema = $self->schema;
#my $json = $self->req->body;
say Dumper( $self->req->json );
# $VAR1 = undef;
my $source;
#my $source = $schema->resultset( 'Source' )->create( $json );
if ( $source ) {
$self->res->code( 200 );
$self->render( json => { source_id => $source->id } );
}
else {
$self->res->code( 422 );
$self->render( json => { error => "Unable to create source." } );
}
};
# This is the PUT request
PUT /source.json HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: e2a040fd-0a0d-7c0c-5759-ea4fc949c4fd
{
'name': 'Test name',
'description': 'Test description',
'url': 'http://domain.com'
}
# Setup
CORE
Perl (v5.18.1, darwin)
Mojolicious (5.24, Tiger Face)
OPTIONAL
EV 4.0+ (not installed)
IO::Socket::IP 0.20+ (not installed)
IO::Socket::Socks 0.64+ (not installed)
IO::Socket::SSL 1.84+ (1.953)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment