public class FileService extends AbstractHttpService
HttpService that serves static files from a file system.FileServiceBuilder| Modifier and Type | Method and Description |
|---|---|
static FileServiceBuilder |
builder(ClassLoader classLoader,
String rootDir)
Returns a new
FileServiceBuilder with the specified rootDir in the current class
path. |
static FileServiceBuilder |
builder(File rootDir)
Returns a new
FileServiceBuilder with the specified rootDir in an O/S file system. |
static FileServiceBuilder |
builder(HttpVfs vfs)
Returns a new
FileServiceBuilder with the specified HttpVfs. |
static FileServiceBuilder |
builder(Path rootDir)
Returns a new
FileServiceBuilder with the specified rootDir in an O/S file system. |
FileServiceConfig |
config()
Returns the configuration.
|
protected HttpResponse |
doGet(ServiceRequestContext ctx,
HttpRequest req)
Handles a
GET request. |
static FileService |
of(ClassLoader classLoader,
String rootDir)
Returns a new
FileService for the specified rootDir in the current class path. |
static FileService |
of(File rootDir)
Returns a new
FileService for the specified rootDir in an O/S file system. |
static FileService |
of(HttpVfs vfs)
Returns a new
FileService for the specified HttpVfs. |
static FileService |
of(Path rootDir)
Returns a new
FileService for the specified rootDir in an O/S file system. |
HttpService |
orElse(HttpService nextService)
Creates a new
HttpService that tries this FileService first and then the specified
HttpService when this FileService 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 FileService of(File rootDir)
FileService for the specified rootDir in an O/S file system.public static FileService of(Path rootDir)
FileService for the specified rootDir in an O/S file system.public static FileService of(ClassLoader classLoader, String rootDir)
FileService for the specified rootDir in the current class path.public static FileService of(HttpVfs vfs)
FileService for the specified HttpVfs.public static FileServiceBuilder builder(File rootDir)
FileServiceBuilder with the specified rootDir in an O/S file system.public static FileServiceBuilder builder(Path rootDir)
FileServiceBuilder with the specified rootDir in an O/S file system.public static FileServiceBuilder builder(ClassLoader classLoader, String rootDir)
FileServiceBuilder with the specified rootDir in the current class
path.public static FileServiceBuilder builder(HttpVfs vfs)
FileServiceBuilder with 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, 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 FileServiceConfig 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 FileService first and then the specified
HttpService when this FileService does not have a requested resource.nextService - the HttpService to try secondlyCopyright © 2020 LeanCloud. All rights reserved.