spring-framework / org.springframework.web.filter.reactive / HiddenHttpMethodFilter

HiddenHttpMethodFilter

open class HiddenHttpMethodFilter : WebFilter

Reactive WebFilter that converts posted method parameters into HTTP methods, retrievable via ServerHttpRequest#getMethod(). Since browsers currently only support GET and POST, a common technique is to use a normal POST with an additional hidden form field (_method) to pass the "real" HTTP method along. This filter reads that parameter and changes the ServerHttpRequest#getMethod() return value using ServerWebExchange#mutate().

The name of the request parameter defaults to _method, but can be adapted via the methodParamName property.

Author
Greg Turnquist

Author
Rossen Stoyanchev

Since
5.0

Constructors

<init>

HiddenHttpMethodFilter()

Reactive WebFilter that converts posted method parameters into HTTP methods, retrievable via ServerHttpRequest#getMethod(). Since browsers currently only support GET and POST, a common technique is to use a normal POST with an additional hidden form field (_method) to pass the "real" HTTP method along. This filter reads that parameter and changes the ServerHttpRequest#getMethod() return value using ServerWebExchange#mutate().

The name of the request parameter defaults to _method, but can be adapted via the methodParamName property.

Properties

DEFAULT_METHOD_PARAMETER_NAME

static val DEFAULT_METHOD_PARAMETER_NAME: String

Default name of the form parameter with the HTTP method to use

Functions

filter

open fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void>

Transform an HTTP POST into another method based on methodParamName

setMethodParamName

open fun setMethodParamName(methodParamName: String): Unit

Set the name of the form parameter with the HTTP method to use.

By default this is set to "_method".