The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WebAPI::DBIC::WebApp

VERSION

version 0.003002

SYNOPSIS

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.

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.

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.

NAME

WebAPI::DBIC::WebApp - Build a Plack app using WebAPI::DBIC

AUTHOR

Tim Bunce <Tim.Bunce@pobox.com>

COPYRIGHT AND LICENSE

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.