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
This commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
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.http.codec.CodecsAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
|
||||
@@ -90,6 +91,7 @@ public class WebFluxAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
|
||||
@ConditionalOnProperty(prefix = "spring.webflux.hiddenmethod.filter", name = "enabled", matchIfMissing = true)
|
||||
public OrderedHiddenHttpMethodFilter hiddenHttpMethodFilter() {
|
||||
return new OrderedHiddenHttpMethodFilter();
|
||||
}
|
||||
|
||||
@@ -1790,6 +1790,12 @@
|
||||
"name": "spring.webservices.wsdl-locations",
|
||||
"type": "java.util.List<java.lang.String>",
|
||||
"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": [
|
||||
|
||||
@@ -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
|
||||
public void customRequestMappingHandlerMapping() {
|
||||
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.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 WEB SERVICES ({sc-spring-boot-autoconfigure}/webservices/WebServicesProperties.{sc-ext}[WebServicesProperties])
|
||||
|
||||
Reference in New Issue
Block a user