Configure WebFlux HiddenHttpMethodFilter with property

This commit adds a new configuration property
`"spring.webflux.hiddenmethod.filter.enable"` that enables/disables the
`HttpHiddenMethodFilter` in Spring WebFlux.

Closes gh-14520
pull/14497/merge
Brian Clozel 6 years ago
parent 7bfc620625
commit 43966c7f93

@ -30,6 +30,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration; import org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration;
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
@ -90,6 +91,7 @@ public class WebFluxAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class) @ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
@ConditionalOnProperty(prefix = "spring.webflux.hiddenmethod.filter", name = "enabled", matchIfMissing = true)
public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() { public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
return new OrderedHiddenHttpMethodFilter(); return new OrderedHiddenHttpMethodFilter();
} }

@ -1790,6 +1790,12 @@
"name": "spring.webservices.wsdl-locations", "name": "spring.webservices.wsdl-locations",
"type": "java.util.List<java.lang.String>", "type": "java.util.List<java.lang.String>",
"description": "Comma-separated list of locations of WSDLs and accompanying XSDs to be exposed as beans." "description": "Comma-separated list of locations of WSDLs and accompanying XSDs to be exposed as beans."
},
{
"name": "spring.webflux.hiddenmethod.filter.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable Spring's HiddenHttpMethodFilter.",
"defaultValue": true
} }
], ],
"hints": [ "hints": [

@ -371,6 +371,14 @@ public class WebFluxAutoConfigurationTests {
}); });
} }
@Test
public void hiddenHttpMethodFilterCanBeDisabled() {
this.contextRunner
.withPropertyValues("spring.webflux.hiddenmethod.filter.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(HiddenHttpMethodFilter.class));
}
@Test @Test
public void customRequestMappingHandlerMapping() { public void customRequestMappingHandlerMapping() {
this.contextRunner.withUserConfiguration(CustomRequestMappingHandlerMapping.class) this.contextRunner.withUserConfiguration(CustomRequestMappingHandlerMapping.class)

@ -519,6 +519,7 @@ content into your application. Rather, pick only the properties that you need.
# SPRING WEBFLUX ({sc-spring-boot-autoconfigure}/web/reactive/WebFluxProperties.{sc-ext}[WebFluxProperties]) # SPRING WEBFLUX ({sc-spring-boot-autoconfigure}/web/reactive/WebFluxProperties.{sc-ext}[WebFluxProperties])
spring.webflux.date-format= # Date format to use. For instance, `dd/MM/yyyy`. spring.webflux.date-format= # Date format to use. For instance, `dd/MM/yyyy`.
spring.webflux.hiddenmethod.filter.enabled=true # Whether to enable Spring's HiddenHttpMethodFilter.
spring.webflux.static-path-pattern=/** # Path pattern used for static resources. spring.webflux.static-path-pattern=/** # Path pattern used for static resources.
# SPRING WEB SERVICES ({sc-spring-boot-autoconfigure}/webservices/WebServicesProperties.{sc-ext}[WebServicesProperties]) # SPRING WEB SERVICES ({sc-spring-boot-autoconfigure}/webservices/WebServicesProperties.{sc-ext}[WebServicesProperties])

Loading…
Cancel
Save