29 Mar 2013 15:30:28 UTC
- Distribution: Dancer-Plugin-Tapir
- Module version: 0.05
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (170 / 53 / 0)
- KwaliteeBus factor: 0
- % Coverage
- License: perl_5
- Perl: v5.6.0
- Activity24 month
- Download (11.69KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionEWATERS Eric Waters
Dancer::Plugin::Tapir - Associate a Tapir handler with Dancer routes
use Dancer; use Dancer::Plugin::Tapir; setup_tapir_handler thrift_idl => 'thrift/service.thrift', handler_class => 'MyAPI::Service';
The goal of this package is to quickly and without fuss expose a Tapir service via Dancer via a RESTful API. Doing so requires no additional coding, and only requires a simple comment added to your Thrift methods.
This plugin exports the method
setup_tapir_handlerinto the caller. Call it with either a list of arguments or using your Dancer configuration (see below).
The handler class must be a subclass of Tapir::Server::Handler::Class and have registered methods for each Thrift method of the Thrift service.
The Dancer routes that will be exposed match up with the
@restThrift documentation tag. For example:
/* Create a new account @rest POST /accounts */ account createAccount ( 1: username username, 2: string password )
This will create a route
POST /accountswhich will call the method
createAccountin the handler class. The Dancer method
paramswill be used to extract both query string and payload parameters, and will be used to compose the thrift message passed to the Tapir::Server::Handler.
Control over the HTTP status code returned to the user is still being worked out, as are being able to set headers in the HTTP response. At the moment, the result is serialized via JSON but will in the future be serialized according to the Accept headers of the request.
Add something like this to your YAML config:
plugins: Tapir: thrift_idl: thrift/service.thrift handler_class: MyAPI::Service
This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself
Copyright (c) 2012 Eric Waters. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Eric Waters <firstname.lastname@example.org>
Module Install Instructions
To install Dancer::LoggerMockObject, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Dancer::LoggerMockObject
For more information on module installation, please visit the detailed CPAN module installation guide.