Interface MimeTypeResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Content-Type value.
Implementations used with StaticFiles must be thread-safe; StaticFiles invokes
resolvers concurrently from request-handling threads.
StaticFiles' default resolver uses a curated deterministic extension map for common web
assets. It does not call Files.probeContentType(Path). A custom resolver
fully replaces that default, and Optional.empty() means no Content-Type header is
emitted.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptioncontentTypeFor(@NonNull Path path) Resolves theContent-Typeforpath.static @NonNull MimeTypeResolverAcquires Soklet's default threadsafeMimeTypeResolver.
-
Method Details
-
contentTypeFor
Resolves theContent-Typeforpath.When configured through
StaticFiles.Builder.mimeTypeResolver(MimeTypeResolver), this resolver fully replaces the default resolver. To extend Soklet's default extension map, delegate todefaultInstance()for paths your implementation does not handle.- Parameters:
path- the resolved file path being served- Returns:
- the content type to emit, or
Optional.empty()to omit it
-
defaultInstance
Acquires Soklet's default threadsafeMimeTypeResolver.The default resolver uses a curated deterministic extension map for common web assets and returns
Optional.empty()for unknown extensions.- Returns:
- the default
MimeTypeResolver
-