Web::Machine Based on Erlang and Pythons WebMachines Automatic
Handling of Status Understands HTTP ow Friday, 25 July 14
Friday, 25 July 14
sub content_types_provided { [ {'application/json' =>
'to_json'}, ]; } sub to_json { my $self = shift; return 404 unless
$response; # A status code was returned return $response if ref
$response eq 'SCALAR'; return JSON::to_json($response), } Friday,
25 July 14
sub get_data { my ($self) = @_; my $params =
$self->db_params; my $page = delete $params->{page} // 1; my
$rows = delete $params->{page_size} // 10; my $resultset =
$self->db_schema->resultset($self->db_table); for my
$param (keys %$params){ return 400 unless
$resultset->result_source->has_column($param); } my $results
= $resultset->search( $params, {page => $page, rows =>
$rows} ); return $self->serialise_results( $results, $params,
$results->pager, $rows ); } Friday, 25 July 14
Problems No routing in Web::Machine What is a Resource? An Row
or a Resultset POST to non existent resource Business logic Friday,
25 July 14
TODO Routing in Web::Machine Resource on the y creation Allow
business override/callbacks Methods for Hypermedia control between
related resources. Friday, 25 July 14