Class RequestedContentTypeResolverBuilder
java.lang.Object
org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder
Builder for a composite
RequestedContentTypeResolver
that delegates
to other resolvers each implementing a different strategy to determine the
requested content type -- for example, Accept header, query parameter, or other.
Use builder methods to add resolvers in the desired order. For a given
request he first resolver to return a list that is not empty and does not
consist of just MediaType.ALL
, will be used.
By default, if no resolvers are explicitly configured, the builder will
add HeaderContentTypeResolver
.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Helper to create and configureParameterContentTypeResolver
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build aRequestedContentTypeResolver
that delegates to the list of resolvers configured through this builder.void
fixedResolver
(MediaType... mediaTypes) Add resolver that returns a fixed set of media types.void
Add resolver to get the requested content type from the "Accept" header.Add a resolver to get the requested content type from a query parameter.void
resolver
(RequestedContentTypeResolver resolver) Add a custom resolver.
-
Constructor Details
-
RequestedContentTypeResolverBuilder
public RequestedContentTypeResolverBuilder()
-
-
Method Details
-
parameterResolver
Add a resolver to get the requested content type from a query parameter. By default the query parameter name is"format"
. -
headerResolver
public void headerResolver()Add resolver to get the requested content type from the "Accept" header. -
fixedResolver
Add resolver that returns a fixed set of media types.- Parameters:
mediaTypes
- the media types to use
-
resolver
Add a custom resolver.- Parameters:
resolver
- the resolver to add
-
build
Build aRequestedContentTypeResolver
that delegates to the list of resolvers configured through this builder.
-