|
|
|
|
@ -690,7 +690,7 @@ reliance on it.
@@ -690,7 +690,7 @@ reliance on it.
|
|
|
|
|
== API Version |
|
|
|
|
[.small]#xref:web/webmvc/mvc-config/api-version.adoc[See equivalent in the Servlet stack]# |
|
|
|
|
|
|
|
|
|
To enable API versioning with a request header, use the following: |
|
|
|
|
To enable API versioning, use the `ApiVersionConfigurer` callback of `WebFluxConfigurer`: |
|
|
|
|
|
|
|
|
|
[tabs] |
|
|
|
|
====== |
|
|
|
|
@ -722,19 +722,30 @@ Kotlin::
@@ -722,19 +722,30 @@ Kotlin::
|
|
|
|
|
---- |
|
|
|
|
====== |
|
|
|
|
|
|
|
|
|
Alternatively, the version can be resolved from a request parameter, from a path segment, |
|
|
|
|
or through a custom `ApiVersionResolver`. |
|
|
|
|
You can resolve the version through one of the built-in options listed below, or |
|
|
|
|
alternatively use a custom `ApiVersionResolver`: |
|
|
|
|
|
|
|
|
|
- Request header |
|
|
|
|
- Request parameter |
|
|
|
|
- Path segment |
|
|
|
|
- Media type parameter |
|
|
|
|
|
|
|
|
|
TIP: When using a path segment, consider configuring a shared path prefix externally |
|
|
|
|
in xref:web/webmvc/mvc-config/path-matching.adoc[Path Matching] options. |
|
|
|
|
|
|
|
|
|
Raw version values are parsed with `SemanticVersionParser` by default, but you can use |
|
|
|
|
By default, the version is parsed with `SemanticVersionParser`, but you can also configure |
|
|
|
|
a custom xref:web/webflux-versioning.adoc#webflux-versioning-parser[ApiVersionParser]. |
|
|
|
|
|
|
|
|
|
"Supported" versions are transparently detected from versions declared in request mappings |
|
|
|
|
for convenience, but you can turn that off through a flag in the WebFlux config, and use only |
|
|
|
|
the versions configured explicitly in the config. Requests with a version that is not |
|
|
|
|
supported are rejected with `InvalidApiVersionException` resulting in a 400 response. |
|
|
|
|
Supported versions are transparently detected from versions declared in request mappings |
|
|
|
|
for convenience, but you can turn that off through a flag in the WebFlux config, and |
|
|
|
|
consider only the versions configured explicitly in the config as supported. |
|
|
|
|
Requests with a version that is not supported are rejected with |
|
|
|
|
`InvalidApiVersionException` resulting in a 400 response. |
|
|
|
|
|
|
|
|
|
You can set an `ApiVersionDeprecationHandler` to send information about deprecated |
|
|
|
|
versions to clients. The built-in standard handler can set "Deprecation", "Sunset", and |
|
|
|
|
"Link" headers based on https://datatracker.ietf.org/doc/html/rfc9745[RFC 9745] and |
|
|
|
|
https://datatracker.ietf.org/doc/html/rfc8594[RFC 8594]. |
|
|
|
|
|
|
|
|
|
Once API versioning is configured, you can begin to map requests to |
|
|
|
|
xref:web/webflux/controller/ann-requestmapping.adoc#webflux-ann-requestmapping-version[controller methods] |
|
|
|
|
|