Versioning of Custom Filters
Please share if there an inbuilt way to run multiple versions of a custom filter allowing a gradual upgrade path.
For Example: If a filter, say, CustomFilter is being used by several routes requires a change that could have a large impact, we would prefer a gradual upgrade process with only selective routes going first. Of-course, we can make multiple copies of the filter, like CustomFilterV1, CustomFilterV2 etc. but that leads to a maintenance overhead.
Is there anything inbuilt to make it easier.
Please share if there an inbuilt way to run multiple versions of a custom filter allowing a gradual upgrade path
not yet
Of-course, we can make multiple copies of the filter, like CustomFilterV1, CustomFilterV2 etc. but that leads to a maintenance overhead. Is there anything inbuilt to make it easier. yes. You may do like this.
example:
public class VersioningGatewayFilterFactory extends AbstractGatewayFilterFactory<VersioningGatewayFilterFactory.Config> {
public VersioningGatewayFilterFactory() {
super(VersioningGatewayFilterFactory.Config.class);
}
@Override
public GatewayFilter apply(Config config) {
return (exchange, chain) -> {
String version = config.version;
// your spec code
return chain.filter(exchange);
};
}
static class Config {
protected String version;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
}
and the config like:
routes:
- id: version1
uri:
predicates:
- Path=/**
filters:
- name: Versioning
args:
version: 1
- id: version2
uri:
predicates:
- Path=/**
filters:
- name: Versioning
args:
version: 2
There is nothing to do this.