PGXN is a CPAN-inspired network for distributing extensions for the PostgreSQL RDBMS. All of the infrastructure tools, however, have been designed to be used to create networks for distributing any kind of release distributions and for providing a lightweight static file JSON REST API.
PGXN::API is a Perl module that provides a superset of the static file REST API, embellishing the metadata in some files and providing additional APIs, including full-text search and browsable access to all packages on the mirror. Hit the PGXN API server for the canonical deployment of this module. Better yet, read the comprehensive API documentation or use WWW::PGXN if you just want to use the API.
There are two simple steps to setting up your own API server using this module:
- pgxn_api_sync
This script syncs to a PGXN mirror via rsync and processes newly-synced data to provide the additional data and APIs. Any PGXN mirror will do. If you need to create your own network of mirrors first, see PGXN::Manager. Consult the pgxn_api_sync documentation for details on its (minimal) options.
- pgxn_api_server
A Plack server for the API. In addition to the usual plackup options, it has a few of its own:
--doc-root
The path to use for the API document root. This is the same directory as you manage via pgxn_api_sync in a cron job. Optional. If not specified, it will default to a directory named www in the parent directory above the PGXN directory in which this module is installed. If you're running the API from a Git checkout, that should be fine. Otherwise you should probably specify a document root or you're you'll never be able to find it.
--errors-to
An email address to which error emails should be sent. In the event of an internal server error, the server will send an email to this address with diagnostic information.
--errors-from
An email address from which alert emails should be sent.
And that's it. If you're interested in the internals of PGXN::API or in hacking on it, read on. Otherwise, just enjoy your own API server!
Synopsis
In a cron job:
* * * * 42 pgxn_api_sync --root /var/www/api rsync://master.pgxn.org/pgxn/
In a system start script:
pgxn_api_server --doc-root /var/www/api \
--errors-from oops@example.com \
--errors-to alerts@example.com
Product's homepage
Requirements:
· Perl