6. API 版本验证
平台需要在每次调用 Open Service Broker API 时提供 HTTP 标头,以指示平台支持的 API 规范版本。 您可以配置 Spring Cloud Open Service Broker 以验证平台在每次调用 Service Broker 时提供的版本。 默认情况下,此版本验证配置为允许任何 API 版本。
要自定义版本验证,请将apiVersion
指定 Service Broker 所需的 API 版本的属性,如下所示:
spring.cloud.openservicebroker.apiVersion=2.13
或者,您也可以提供BrokerApiVersion
Spring bean 中,如下所示:
package com.example.servicebroker;
@Configuration
public class ExampleApiVersionConfiguration {
@Bean
public BrokerApiVersion brokerApiVersion() {
return new BrokerApiVersion("2.13");
}
}
In the case of both a Spring Bean and a property being configured, the Spring Bean takes precedence over the property.
If an API version is specified and the platform provides a different version in the X-Broker-API-Version
header, the framework returns a 412 Precondition Failed
error to the platform.
As mentioned earlier, the default version verification is configured to allow any API version.
However, to disable version verification entirely, you can set the api-version-check-endabled
property to false
, as follows:
spring.cloud.openservicebroker.api-version-check-enabled = false