Modifier and Type | Class and Description |
---|---|
static class |
ResourceHandler.Builder |
Constructor and Description |
---|
ResourceHandler(ResourceProviderFactory resourceProviderFactory,
String pathToServeFrom,
String defaultFile,
Map<String,ResourceType> extensionToResourceType,
int bufferSizeInBytes) |
Modifier and Type | Method and Description |
---|---|
static ResourceHandler.Builder |
classpathHandler(String classpathRoot) |
static ResourceHandler.Builder |
fileHandler(File baseDirectory) |
static ResourceHandler.Builder |
fileHandler(Path path) |
static ResourceHandler.Builder |
fileHandler(String directoryPath) |
static ResourceHandler.Builder |
fileOrClasspath(String fileRootIfExists,
String classpathRoot)
Creates a resource handler that serves from the file system if the directory exists; otherwise from the class path.
|
boolean |
handle(MuRequest request,
MuResponse response) |
public ResourceHandler(ResourceProviderFactory resourceProviderFactory, String pathToServeFrom, String defaultFile, Map<String,ResourceType> extensionToResourceType, int bufferSizeInBytes)
public boolean handle(MuRequest request, MuResponse response) throws Exception
public static ResourceHandler.Builder fileHandler(String directoryPath)
public static ResourceHandler.Builder fileHandler(File baseDirectory)
public static ResourceHandler.Builder fileHandler(Path path)
public static ResourceHandler.Builder classpathHandler(String classpathRoot)
public static ResourceHandler.Builder fileOrClasspath(String fileRootIfExists, String classpathRoot)
A common use case is for when you want to serve from the file path at development time (so you can update files without restarting) but at deploy time resources are packaged in an uber jar.
fileRootIfExists
- A path to a directory holding static content, which may not exist, e.g. src/main/resources/web
classpathRoot
- A classpath path to a directory holding static content, e.g. /web
Copyright © 2017–2018. All rights reserved.