public class ClasspathFilesHandler extends Object implements StaticFilesHandler
Retrieves the URI of the request and tries to find a matching resource in the application class path.
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)
).
Modifier and Type | Class and Description |
---|---|
static class |
ClasspathFilesHandler.ClasspathFilesHandlerBuilder
ClasspathFilesHandler builder. |
Modifier and Type | Method and Description |
---|---|
static ClasspathFilesHandler.ClasspathFilesHandlerBuilder |
builder()
Build an instance of
ClasspathFilesHandler . |
InputStream |
serve(String path,
Map<String,String> headers)
The generic behavior of this request handler implementation is to find a resource matching the given path in the
classpath.
|
public static ClasspathFilesHandler.ClasspathFilesHandlerBuilder builder()
ClasspathFilesHandler
.ClasspathFilesHandler.ClasspathFilesHandlerBuilder
@Nullable public InputStream serve(String path, Map<String,String> headers)
serve
in interface StaticFilesHandler
path
- file pathheaders
- the response headersnull
if the file is not found.