Peter Karman > Search-OpenSearch-Server-0.26 > Search::OpenSearch::Server::Plack

Download:
Search-OpenSearch-Server-0.26.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.26   Source   Latest Release: Search-OpenSearch-Server-0.300

NAME ^

Search::OpenSearch::Server::Plack - serve OpenSearch results with Plack

SYNOPSIS ^

 # 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,
    stats_logger  => MyStats->new(),
 )->to_app;

 builder {
    mount '/' => $app;
 };

 
 # run the app
 % plackup yourapp.psgi

DESCRIPTION ^

Search::OpenSearch::Server::Plack is a Plack::Component application. This module implements a HTTP-ready Search::OpenSearch server using Plack.

METHODS ^

This class inherits from Search::OpenSearch::Server and Plack::Component. Only new or overridden methods are documented here.

new( params )

Inherits from Plack::Component. params can be:

engine

A Search::OpenSearch::Engine instance. Either this or engine_config is required.

engine_config

A hashref passed to the Search::OpenSearch->engine method. Either this or engine is required.

stats_logger

An object that implements at least one method called log. The object's log method is invoked with 2 arguments: the Plack::Request object, and either the Search::OpenSearch::Response object or the REST response hashref, on each request.

call

Implements the required Middleware method. The default behavior is to instantiate a Plack::Request and pass it into do_search().

log( msg, level )

Passes msg on to the Plack::Request->logger object, if any.

prepare_app

Calls setup_engine().

setup_engine

Instantiates the Search::OpenSearch::Engine, if necessary, using the values set in engine_config().

do_rest_api( request, response )

Overrides base Server method to call finalize() on response.

do_search( request, response )

Overrides base Server method to call finalize() on response.

AUTHOR ^

Peter Karman, <karman at cpan.org>

BUGS ^

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.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc Search::OpenSearch::Server

You can also look for information at:

COPYRIGHT & LICENSE ^

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.

syntax highlighting: