Package com.linecorp.armeria.server.file
Class FileService
java.lang.Object
com.linecorp.armeria.server.AbstractHttpService
com.linecorp.armeria.server.file.FileService
- All Implemented Interfaces:
Unwrappable
,HttpService
,Service<HttpRequest,
HttpResponse>
An
HttpService
that serves static files from a file system.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic FileServiceBuilder
Returns a newFileServiceBuilder
with the specifiedHttpVfs
.static FileServiceBuilder
Returns a newFileServiceBuilder
with the specifiedrootDir
in an O/S file system.static FileServiceBuilder
builder
(ClassLoader classLoader, String rootDir) Returns a newFileServiceBuilder
with the specifiedrootDir
in the current class path.static FileServiceBuilder
Returns a newFileServiceBuilder
with the specifiedrootDir
in an O/S file system.config()
Returns the configuration.protected HttpResponse
doGet
(ServiceRequestContext ctx, HttpRequest req) Handles aGET
request.static FileService
Returns a newFileService
for the specifiedHttpVfs
.static FileService
Returns a newFileService
for the specifiedrootDir
in an O/S file system.static FileService
of
(ClassLoader classLoader, String rootDir) Returns a newFileService
for the specifiedrootDir
in the current class path.static FileService
Returns a newFileService
for the specifiedrootDir
in an O/S file system.orElse
(HttpService nextService) Creates a newHttpService
that tries thisFileService
first and then the specifiedHttpService
when thisFileService
does not have a requested resource.void
Invoked when this service has been added to aServer
with the specified configuration.boolean
shouldCachePath
(String path, @Nullable String query, Route route) Returns whether the givenpath
andquery
should be cached if the service's result is successful.Methods inherited from class com.linecorp.armeria.server.AbstractHttpService
doConnect, doDelete, doHead, doOptions, doPatch, doPost, doPut, doTrace, serve
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.server.HttpService
decorate, decorate
-
Method Details
-
of
Returns a newFileService
for the specifiedrootDir
in an O/S file system. -
of
Returns a newFileService
for the specifiedrootDir
in an O/S file system. -
of
Returns a newFileService
for the specifiedrootDir
in the current class path. -
of
Returns a newFileService
for the specifiedHttpVfs
. -
builder
Returns a newFileServiceBuilder
with the specifiedrootDir
in an O/S file system. -
builder
Returns a newFileServiceBuilder
with the specifiedrootDir
in an O/S file system. -
builder
Returns a newFileServiceBuilder
with the specifiedrootDir
in the current class path. -
builder
Returns a newFileServiceBuilder
with the specifiedHttpVfs
. -
serviceAdded
Description copied from interface:Service
Invoked when this service has been added to aServer
with the specified configuration. Please note that this method can be invoked more than once if this service has been added more than once.- Throws:
Exception
-
shouldCachePath
Description copied from interface:Service
Returns whether the givenpath
andquery
should be cached if the service's result is successful. By default, exact path mappings with no input query are cached. -
config
Returns the configuration. -
doGet
Description copied from class:AbstractHttpService
Handles aGET
request. This method sends a405 Method Not Allowed
response by default.- Overrides:
doGet
in classAbstractHttpService
- Throws:
Exception
-
orElse
Creates a newHttpService
that tries thisFileService
first and then the specifiedHttpService
when thisFileService
does not have a requested resource.- Parameters:
nextService
- theHttpService
to try secondly
-