Package ej.hoka.http.requesthandler
Class ClasspathFilesHandler
- java.lang.Object
-
- ej.hoka.http.requesthandler.ClasspathFilesHandler
-
- All Implemented Interfaces:
StaticFilesHandler
public class ClasspathFilesHandler extends java.lang.Object implements StaticFilesHandler
Class path Files Handler .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.htmlin the application's classpath (usingClass.getResourceAsStream(String)).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClasspathFilesHandler.ClasspathFilesHandlerBuilderClasspathFilesHandlerbuilder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ClasspathFilesHandler.ClasspathFilesHandlerBuilderbuilder()Build an instance ofClasspathFilesHandler.java.io.InputStreamserve(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> headers)The generic behavior of this request handler implementation is to find a resource matching the given path in the classpath.
-
-
-
Method Detail
-
builder
public static ClasspathFilesHandler.ClasspathFilesHandlerBuilder builder()
Build an instance ofClasspathFilesHandler.- Returns:
- instance of
ClasspathFilesHandler.ClasspathFilesHandlerBuilder
-
serve
@Nullable public java.io.InputStream serve(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> headers)The generic behavior of this request handler implementation is to find a resource matching the given path in the classpath.- Specified by:
servein interfaceStaticFilesHandler- Parameters:
path- file pathheaders- the response headers- Returns:
- the file input stream or code
nullif the file is not found.
-
-