NAME
Plack::App::unAPI - Serve via unAPI
VERSION
version 0.1
SYNOPSIS
use Plack::App::unAPI;
my $app1 = sub { ... };
my $app2 = sub { ... };
my $app3 = sub { ... };
unAPI
json => [ $app1 => 'application/javascript' ],
xml => [ $app2 => 'application/xml' ],
txt => [ $app3 => 'text/plain', docs => 'http://example.com' ];
To run this script you can simply call plackup yourscript.psgi
.
DESCRIPTION
This implements an unAPI server as PSGI application. unAPI is a tiny HTTP API to query discretely identified objects in different formats. See http://unapi.info for details.
METHODS
new ( %formats )
To create an new object you must provide a list of mappings between format names and PSGI applications to serve requests for the particular format. Each application is wrapped in an array reference, followed by its MIME type and optional information fields about the format. So the general form is:
format => [ $app => $type, %about ]
The following information fields are supported:
- docs
-
An URL of a document that describes the format
unAPI ( %formats )
The unAPI
keyword as constructor alias is exported by default. To prevent exporting, include this module via use Plack::App::unAPI ();
.
formats ( [$id] )
Returns a PSGI response with status 300 (Multiple Choices) and an XML document that lists all formats.
AUTHOR
Jakob Voss
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Jakob Voss.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.