WebAPI::DBIC - Automated RESTful API's

12
WebAPI::DBIC WebAPI::DBIC

Transcript of WebAPI::DBIC - Automated RESTful API's

WebAPI::DBICWebAPI::DBIC

RESTful ToolKitRESTful ToolKitA Series of useful Moo::RolesEach providing a specific part ofthe wholeHandling for Sets and ItemsBuilt with DBIx::Class

Strong foundationsStrong foundationsWeb::Machine - HTTP StateEnginePlack - Light, extensible HTTPServerPath::Router - Reversible urihandling

Incomprehensive ImageIncomprehensive Image

WebAPI::DBIC::WebAPP

WebAPI::DBIC::Resource::Item

WebAPI::DBIC::Resource::Set

DBIx::Class::ResultSource

Plack

Auto ConfigurationAuto ConfigurationSensible defaultsExposes all DBIX ResultSourcesProvides HTTP Verb supportRange of Data Serializers basedon Accept: headersHandles HTTP State automagically

Example 1Example 1ChinookChinook

Structure OldStructure OldController - Handles Routing,HTTP validation, Domain modelsetup, handles ViewModel - Handles business logic,dataView - Handles data serialization

Structure NewStructure NewRouter - Handles the paths to eachresourceResource - Handles the actualRequestDBIC ResultSource - Handlesbusiness logic, data

MyApp- Controllers - Auth - Note - Healthcheck- Model - Note- Exception- Schema - Result - Note

MyApp- Resource - Note - Notes- Schema - Result - Note

package MyApp::Resource::Note;

use Moo;

extends 'WebAPI::DBIC::Resource::GenericItem';

sub forbidden { my ($self) = @_;

my $headers = $self->request->headers; return 1 unless $headers->authorization_basic;

my ($username, $password) = $headers->authorization_basic; return 1 unless # Some check for userpass auth

return 0; # Is Authorized}

Example 2Example 2Candidate::WebService::NoteCandidate::WebService::Note

ConclusionConclusionUnder Rapid Development (Alpha)Aimed for easy of customizationProvides sensible out of the boxdefaultsFollows REST best practices (asfar as they exist)