Catalyst-Controller-ElasticSearch
view release on metacpan or search on metacpan
lib/Catalyst/Controller/ElasticSearch.pm view on Meta::CPAN
version 0.1.0
=head1 DESCRIPTION
This controller base class provides some basic protection for your ElasticSearch
server. This will allow you to publish individual indices and types through
your Catalyst application. The controller will prevent malicious requests
such as huge size parameters or scripts.
ElasticSearch's C<_search> endpoint is very powerful. And with power comes great
responsibility. Instead of providing the vanilla search endpoint, it is recommeded
that you predefine searches that process only certain parameters. See L</DISABLING FEATURES>.
B<< Exposing ElasticSearch to the Internet is dangerous. MetaCPAN is doing it,
and this module is the result of what we've learned so far. >>
=head2 SYNOPSIS
package MyApp::Model::ElasticSearch;
use Moose;
use ElasticSearch
lib/Catalyst/Controller/ElasticSearch.pm view on Meta::CPAN
$model->es->search(
index => $self->index,
type => $self->type,
size => $model->size,
) );
} or do { $c->detach("error", [500, $@]) };
}
=head1 ENDPOINTS
By default, this controller will create the following endpoints for a controller
named C<MyApp::Controller::Tweet>.
=head2 mapping
/twitter/tweet/_mapping
This will return the ElasticSearch mapping.
=head2 get
/twitter/tweet/$id
Will return the document C<$id>. If L</raw_get> is set to false, the returned
JSON will not include the ElasticSearch metadata. Instead the C<_source> or
C<fields> property is returned.
=head2 all
/twitter/tweet
This endpoint is equivalent to C</tweet/_search?q=*>.
=head2 search
/twitter/tweet/_search
This endpoint proxies to the search endpoint of ElasticSearch. However, it will
sanitize the query first.
=head1 ACCESS CONTROL
As with other controllers, you would do the access control in the C<auto>
action.
sub auto : Private {
my ($self, $c) = @_;
return $c->detach("error", [403, "Unauthorized"])
( run in 0.228 second using v1.01-cache-2.11-cpan-b61123c0432 )