Package com.linecorp.armeria.server.file
Interface MediaTypeResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A function used for determining the
MediaType
of a file based on its path.-
Method Summary
Modifier and TypeMethodDescriptionguessFromPath
(String path, @Nullable String contentEncoding) Resolves theMediaType
of the file referred by the givenpath
assuming the file is encoded in the givencontentEncoding
.static MediaTypeResolver
Returns the defaultMediaTypeResolver
.default MediaTypeResolver
orElse
(MediaTypeResolver other) Returns a newly createdMediaTypeResolver
that tries thisMediaTypeResolver
first and then the specifiedother
when the first call returnsnull
.
-
Method Details
-
ofDefault
Returns the defaultMediaTypeResolver
. -
guessFromPath
@Nullable @Nullable MediaType guessFromPath(String path, @Nullable @Nullable String contentEncoding) Resolves theMediaType
of the file referred by the givenpath
assuming the file is encoded in the givencontentEncoding
.- Parameters:
path
- the path of the file to resolve itsMediaType
, e.g"/foo/bar.txt"
,"bar.txt"
or"/foo/bar.txt.gz"
in a compressed form.contentEncoding
- the content encoding, such as"gzip"
and"br"
, as defined in the section 3.5, RFC 2616.null
or"identity"
for an uncompressed file.- Returns:
- the resolved
MediaType
-
orElse
Returns a newly createdMediaTypeResolver
that tries thisMediaTypeResolver
first and then the specifiedother
when the first call returnsnull
.
-