Polish gh-2742
Added overridden method in GatewayFilterSpec and updated DisableBuiltInFiltersTests to include new filter.
This commit is contained in:
@@ -465,11 +465,22 @@ public class GatewayFilterSpec extends UriSpec {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A filter that can be used to modify the response body. By default, this only
|
||||
* removes root attributes.
|
||||
* @param attributes list of attributes to remove.
|
||||
* @return a {@link GatewayFilterSpec} that can be used to apply additional filters
|
||||
*/
|
||||
public GatewayFilterSpec removeJsonAttributes(String... attributes) {
|
||||
return removeJsonAttributes(false, attributes);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A filter that can be used to modify the response body.
|
||||
* @param attributes list of attributes to remove separated by commas, an optional
|
||||
* last parameter from the list can be a boolean to remove the attributes just at root
|
||||
* level (false) o recursively (true)
|
||||
* @param attributes list of attributes to remove.
|
||||
* @param deleteRecursively if true, all attributes regardless of nesting will be
|
||||
* removed.
|
||||
* @return a {@link GatewayFilterSpec} that can be used to apply additional filters
|
||||
*/
|
||||
public GatewayFilterSpec removeJsonAttributes(boolean deleteRecursively, String... attributes) {
|
||||
|
||||
@@ -90,6 +90,7 @@ public class DisableBuiltInFiltersTests {
|
||||
"spring.cloud.gateway.filter.prefix-path.enabled=false",
|
||||
"spring.cloud.gateway.filter.preserve-host-header.enabled=false",
|
||||
"spring.cloud.gateway.filter.redirect-to.enabled=false",
|
||||
"spring.cloud.gateway.filter.remove-json-attributes-response-body.enabled=false",
|
||||
"spring.cloud.gateway.filter.remove-request-header.enabled=false",
|
||||
"spring.cloud.gateway.filter.remove-request-parameter.enabled=false",
|
||||
"spring.cloud.gateway.filter.remove-response-header.enabled=false",
|
||||
|
||||
@@ -110,7 +110,7 @@ public class RemoveJsonAttributesResponseBodyGatewayFilterFactoryTests extends B
|
||||
.filters(f -> f.removeJsonAttributes(true, "foo")).uri(uri))
|
||||
.route("remove_json_attributes_no_matches_java_test",
|
||||
r -> r.path("/post").and().host("{sub}.removejsonattributesnomatches.org")
|
||||
.filters(f -> f.removeJsonAttributes(false, "test")).uri(uri))
|
||||
.filters(f -> f.removeJsonAttributes("test")).uri(uri))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user