public final class HttpFileService extends AbstractHttpService
HttpService that serves static files from a file system.HttpFileServiceBuilder| Modifier and Type | Method and Description |
|---|---|
HttpFileServiceConfig |
config()
Returns the configuration.
|
protected HttpResponse |
doGet(ServiceRequestContext ctx,
HttpRequest req)
Handles a
GET request. |
static HttpFileService |
forClassPath(ClassLoader classLoader,
String rootDir)
Creates a new
HttpFileService for the specified rootDir in the current class path. |
static HttpFileService |
forClassPath(String rootDir)
Creates a new
HttpFileService for the specified rootDir in the current class path. |
static HttpFileService |
forFileSystem(Path rootDir)
Creates a new
HttpFileService for the specified rootDir in an O/S file system. |
static HttpFileService |
forFileSystem(String rootDir)
Creates a new
HttpFileService for the specified rootDir in an O/S file system. |
static HttpFileService |
forVfs(HttpVfs vfs)
Creates a new
HttpFileService for the specified HttpVfs. |
HttpService |
orElse(HttpService nextService)
Creates a new
HttpService that tries this HttpFileService first and then the specified
HttpService when this HttpFileService does not have a requested resource. |
void |
serviceAdded(ServiceConfig cfg)
Invoked when this service has been added to a
Server with the specified
configuration. |
boolean |
shouldCachePath(String path,
String query,
Route route)
Returns whether the given
path and query should be cached if the service's result is
successful. |
doDelete, doDelete, doGet, doHead, doHead, doOptions, doOptions, doPatch, doPatch, doPost, doPost, doPut, doPut, doTrace, doTrace, serveclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdecorate, decoratepublic static HttpFileService forFileSystem(String rootDir)
HttpFileService for the specified rootDir in an O/S file system.public static HttpFileService forFileSystem(Path rootDir)
HttpFileService for the specified rootDir in an O/S file system.public static HttpFileService forClassPath(String rootDir)
HttpFileService for the specified rootDir in the current class path.public static HttpFileService forClassPath(ClassLoader classLoader, String rootDir)
HttpFileService for the specified rootDir in the current class path.public static HttpFileService forVfs(HttpVfs vfs)
HttpFileService for the specified HttpVfs.public void serviceAdded(ServiceConfig cfg) throws Exception
ServiceServer with the specified
configuration. Please note that this method can be invoked more than once if this service
has been added more than once.Exceptionpublic boolean shouldCachePath(String path, @Nullable String query, Route route)
Servicepath and query should be cached if the service's result is
successful. By default, exact path mappings with no input query are cached.public HttpFileServiceConfig config()
protected HttpResponse doGet(ServiceRequestContext ctx, HttpRequest req) throws Exception
AbstractHttpServiceGET request.
This method sends a 405 Method Not Allowed response by default.doGet in class AbstractHttpServiceExceptionpublic HttpService orElse(HttpService nextService)
HttpService that tries this HttpFileService first and then the specified
HttpService when this HttpFileService does not have a requested resource.nextService - the HttpService to try secondlyCopyright © 2020 LeanCloud. All rights reserved.