public class ResourceRequestHandler extends java.lang.Object implements RequestHandler
Retrieves the URI of the request and tries to find a matching resource.
Example:
Given the URI http://192.168.1.1/my/wonderful/resource.html, the Resource Request Handler, with root
directory /my/package/ will try to find the resource /my/package/my/wonderful/resource.html
in the application's classpath (using Class.getResourceAsStream(String)).
| Constructor and Description |
|---|
ResourceRequestHandler(java.lang.String rootDirectory)
Constructs a resource request handler with given root directory path.
|
ResourceRequestHandler(java.lang.String rootDirectory,
java.lang.String index)
Constructs a resource request handler with given root directory path.
|
| Modifier and Type | Method and Description |
|---|---|
HTTPResponse |
process(HTTPRequest request,
java.util.Map<java.lang.String,java.lang.String> attributes)
The generic behavior of this request handler implementation is to find a resource matching the given URI in the
classpath.
|
public ResourceRequestHandler(java.lang.String rootDirectory)
In case the requested resource is a directory, the "index.html" resource in this directory, if it
exists, is sent.
rootDirectory - the path of the root directory for resources to serve.public ResourceRequestHandler(java.lang.String rootDirectory,
java.lang.String index)
In case the requested resource is a directory, the index resource in this directory, if it exists,
is sent.
rootDirectory - the path of the root directory for resources to serve.index - the directory index file name to serve in case a directory is requested.public HTTPResponse process(HTTPRequest request, java.util.Map<java.lang.String,java.lang.String> attributes)
process in interface RequestHandlerrequest - the HTTPRequestattributes - the attributes of the request.HTTPResponse containing the resource, or null if not found.