WebAPI::DBIC::WebApp
version 0.003002
This most simple example:
$app = WebAPI::DBIC::WebApp->new({ schema => $schema, })->to_psgi_app;
is the same as:
$app = WebAPI::DBIC::WebApp->new({ schema => $schema, routes => [ $schema->sources ], })->to_psgi_app;
which is the same as:
$app = WebAPI::DBIC::WebApp->new({ schema => $schema, routes => [ $schema->sources ], route_maker => WebAPI::DBIC::RouteMaker->new( resource_class_for_item => 'WebAPI::DBIC::Resource::GenericItem', resource_class_for_item_invoke => 'WebAPI::DBIC::Resource::GenericItemInvoke', resource_class_for_set => 'WebAPI::DBIC::Resource::GenericSet', resource_class_for_set_invoke => 'WebAPI::DBIC::Resource::GenericSetInvoke', resource_default_args => { }, type_namer => WebAPI::DBIC::TypeNamer->new( # EXPERIMENTAL type_name_inflect => 'singular', # XXX will change to plural soon type_name_style => 'under_score', # or 'camelCase' etc ), ), })->to_psgi_app;
The elements in routes are passed to the specified route_maker. The elements can include any mix of result source names, as in the example above, resultset objects, and WebAPI::DBIC::Route objects.
routes
route_maker
Result source names are converted to resultset objects.
The WebAPI::DBIC::RouteMaker object converts the resultset objects into a set of WebAPI::DBIC::Routes, e.g, foo/ for the resultset and foo/:id for an item of the set.
foo/
foo/:id
The path prefix, i.e., foo is determined from the resultset using the type_name_inflect and type_name_style to define the route path, and the resource_class_for_* to define the resource classes that the routes should refer to.
foo
type_name_inflect
type_name_style
resource_class_for_*
WebAPI::DBIC::WebApp - Build a Plack app using WebAPI::DBIC
Tim Bunce <Tim.Bunce@pobox.com>
This software is copyright (c) 2015 by Tim Bunce.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install WebAPI::DBIC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebAPI::DBIC
CPAN shell
perl -MCPAN -e shell install WebAPI::DBIC
For more information on module installation, please visit the detailed CPAN module installation guide.