Skip to content

Instantly share code, notes, and snippets.

@phillipadsmith
Created August 4, 2014 00:33
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/fe8a4bb9341118f1eff0 to your computer and use it in GitHub Desktop.
Save phillipadsmith/fe8a4bb9341118f1eff0 to your computer and use it in GitHub Desktop.
any['put','post'] => '/sources' => sub {
my $self = shift;
my $schema = $self->schema;
my $json = $self->req->json;
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." } );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment