This document explains how to implement and deploy a custom request handler.
In most cases, implementing your own request handlers is unnecessary, as both searchers and processors can access the request data directly. However, there are a few cases where custom request handlers are useful:
Upon receiving a request, the request handler must consume its content, process it, and then return a response. The most convenient way to implement a request handler is by subclassing the ThreadedHttpRequestHandler.
This utility base class uses a synchronous API and a multi-threaded execution model. It also implements a lot of functionality that is needed by most request handlers:
The Vespa sample apps on GitHub contains a few example request handler implementations:
|SiteHandler||A handler implementing a custom REST API|
|DemoHandler||A handler that modifies a request before dispatching it to the
To deploy a request handler in an application, use the handler element in services.xml:
<container id="default" version="1.0"> <handler id="my.package.MyRequestHandler" bundle="the name in <artifactId> in your pom.xml"> <binding>http://*/*</binding> </handler>
A request handler may be bound to zero or more URI patterns by adding a binding element for each pattern.