public abstract class AbstractMappingContentTypeResolver extends Object implements MappingContentTypeResolver
MappingContentTypeResolver implementations.
Maintains the actual mappings and pre-implements the overall algorithm with
sub-classes left to provide a way to extract the lookup key (e.g. file
extension, query parameter, etc) for a given exchange.| Constructor and Description |
|---|
AbstractMappingContentTypeResolver(Map<String,org.springframework.http.MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract String |
extractKey(org.springframework.web.server.ServerWebExchange exchange)
Extract the key to use to look up a media type from the given exchange,
e.g.
|
protected List<org.springframework.http.MediaType> |
getAllMediaTypes()
Sub-classes can use this method get all mapped media types.
|
Set<String> |
getKeys()
Return all registered keys (e.g.
|
Set<String> |
getKeysFor(org.springframework.http.MediaType mediaType)
Resolve the given media type to a list of path extensions.
|
protected org.springframework.http.MediaType |
getMediaType(String key)
Sub-classes can use this method to look up a MediaType by key.
|
Map<String,org.springframework.http.MediaType> |
getMediaTypes() |
protected void |
handleMatch(String key,
org.springframework.http.MediaType mediaType)
Override to provide handling when a key is successfully resolved via
getMediaType(String). |
protected org.springframework.http.MediaType |
handleNoMatch(String key)
Override to provide handling when a key is not resolved via.
|
List<org.springframework.http.MediaType> |
resolveMediaTypes(org.springframework.web.server.ServerWebExchange exchange)
Resolve the given request to a list of requested media types.
|
List<org.springframework.http.MediaType> |
resolveMediaTypes(String key)
An overloaded resolve method with a pre-resolved lookup key.
|
protected org.springframework.http.MediaType getMediaType(String key)
key - the key converted to lower casenullprotected List<org.springframework.http.MediaType> getAllMediaTypes()
public List<org.springframework.http.MediaType> resolveMediaTypes(org.springframework.web.server.ServerWebExchange exchange) throws org.springframework.web.server.NotAcceptableStatusException
RequestedContentTypeResolverresolveMediaTypes in interface RequestedContentTypeResolverexchange - the current exchangeorg.springframework.web.server.NotAcceptableStatusException - if the requested media types is invalidpublic List<org.springframework.http.MediaType> resolveMediaTypes(String key) throws org.springframework.web.server.NotAcceptableStatusException
key - the key for looking up media typesorg.springframework.web.server.NotAcceptableStatusExceptionprotected abstract String extractKey(org.springframework.web.server.ServerWebExchange exchange)
nullprotected void handleMatch(String key, org.springframework.http.MediaType mediaType)
getMediaType(String).protected org.springframework.http.MediaType handleNoMatch(String key) throws org.springframework.web.server.NotAcceptableStatusException
getMediaType(String). If a MediaType is returned from
this method it will be added to the mappings.org.springframework.web.server.NotAcceptableStatusExceptionpublic Set<String> getKeysFor(org.springframework.http.MediaType mediaType)
MappingContentTypeResolvergetKeysFor in interface MappingContentTypeResolvermediaType - the media type to resolvenullpublic Set<String> getKeys()
MappingContentTypeResolvergetKeys in interface MappingContentTypeResolvernull