Package org.springframework.web.accept
Interface ApiVersionStrategy
- All Known Implementing Classes:
DefaultApiVersionStrategy
public interface ApiVersionStrategy
The main component that encapsulates configuration preferences and strategies
to manage API versioning for an application.
- Since:
- 7.0
- Author:
- Rossen Stoyanchev
-
Method Summary
Modifier and TypeMethodDescriptionReturn a default version to use for requests that don't specify one.Comparable<?>
parseVersion
(String version) Parse the version of a request into an Object.resolveVersion
(HttpServletRequest request) Resolve the version value from a request, e.g.void
validateVersion
(@Nullable Comparable<?> requestVersion, HttpServletRequest request) Validate a request version, including required and supported version checks.
-
Method Details
-
resolveVersion
Resolve the version value from a request, e.g. from a request header.- Parameters:
request
- the current request- Returns:
- the version, if present or
null
-
parseVersion
Parse the version of a request into an Object.- Parameters:
version
- the value to parse- Returns:
- an Object that represents the version
-
validateVersion
void validateVersion(@Nullable Comparable<?> requestVersion, HttpServletRequest request) throws MissingApiVersionException, InvalidApiVersionException Validate a request version, including required and supported version checks.- Parameters:
requestVersion
- the version to validaterequest
- the request- Throws:
MissingApiVersionException
- if the version is required, but not specifiedInvalidApiVersionException
- if the version is not supported
-
getDefaultVersion
@Nullable Comparable<?> getDefaultVersion()Return a default version to use for requests that don't specify one.
-