Articulate::Service - provide an API to all the core Articulate features.
The Articulate Service provides programmatic access to all the core features of the Articulate app. It is the intermediary between the routes and all other components.
Mostly, you will want to be calling the service in routes, for instance:
get 'zone/:zone_name/article/:article_name' => sub { my ($zone_name, $article_name) = param('zone_name'), param('article_name'); return $self->process_request ( read => "/zone/$zone_name/article/$article_name' ) }
However, you may also want to call it from one-off scripts, tests, etc., especially where you want to perform tasks which you don't want to make available in routes, or where you are already in a perl environment and mapping to the HTTP layer would be a distraction. In theory you could create an application which did not have any web interface at all using this service, e.g. a command-line app on a shared server.
my $response = service->process_request($request); my $response = service->process_request($verb => $data);
This is the primary method of the service: Pass in an Articulate::Request object and the Service will produce a Response object to match.
Alternatively, if you pass a string as the first argument, the request will be created from the verb and the data.
Which verbs are handled, what data they require, and how they will be processed are determined by the service providers you have set up in your config: process_request passes the request to each of the providers in turn and asks them to process the request.
process_request
Providers can decline to process the request by returning undef, which will cause the service to offer the requwst to the next provider.
Note that a provider MAY act on a request and still return undef, e.g. to perform logging, however it is discouraged to perform acctions which a user would typically expect a response from (e.g. a create action should return a response and not just pass to a get to confirm it has successfully created what it was suppsed to).
my @verbs = @{ $self->enumerate_verbs };
Returns an arrayref of verbs which at list one provider will process.
Articulate::Role::Service
Articulate::Request
Articulate::Response
To install Articulate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Articulate
CPAN shell
perl -MCPAN -e shell install Articulate
For more information on module installation, please visit the detailed CPAN module installation guide.