Search::OpenSearch::Server::Plack - serve OpenSearch results with Plack
# write a PSGI application in yourapp.psgi use strict; use warnings; use Plack::Builder; use Search::OpenSearch::Server::Plack; my $engine_config = { type => 'Lucy', index => ['path/to/your/index'], facets => { names => [qw( topics people places orgs author )], sample_size => 10_000, }, fields => [qw( topics people places orgs author )], }; my $app = Search::OpenSearch::Server::Plack->new( engine_config => $engine_config ); builder { mount '/' => $app; }; # run the app % plackup yourapp.psgi
Search::OpenSearch::Server::Plack is a Plack::Middleware application. This module implements a HTTP-ready Search::OpenSearch server using Plack.
Implements the required Middleware method. The default behavior is to instantiate a Plack::Request and pass it into do_search().
Calls setup_engine().
Instantiates the Search::OpenSearch::Engine, if necessary, using the values set in engine_config().
The meat of the application. This method checks params in request, mapping them to the Search::OpenSearch::Engine API.
Returns a Plack::Reponse, finalize()d.
If the Engine used supports has_rest_api(), this method calls the appropriate HTTP method on the Engine object.
The following HTTP headers are supported for explicitly setting the indexer behavior:
If no 'q' param is present in the Plack::Request, this method is called. The default behavior is to set a 400 (bad request) with error message. You can override it to behave more kindly.
Peter Karman, <karman at cpan.org>
<karman at cpan.org>
Please report any bugs or feature requests to bug-search-opensearch-server at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-OpenSearch-Server. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-search-opensearch-server at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Search::OpenSearch::Server
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Search-OpenSearch-Server
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Search-OpenSearch-Server
CPAN Ratings
http://cpanratings.perl.org/d/Search-OpenSearch-Server
Search CPAN
http://search.cpan.org/dist/Search-OpenSearch-Server/
Copyright 2010 Peter Karman.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Search::OpenSearch::Server, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Search::OpenSearch::Server
CPAN shell
perl -MCPAN -e shell install Search::OpenSearch::Server
For more information on module installation, please visit the detailed CPAN module installation guide.