Class HttpsRedirectWebFilter

  • All Implemented Interfaces:
    org.springframework.web.server.WebFilter

    public final class HttpsRedirectWebFilter
    extends java.lang.Object
    implements org.springframework.web.server.WebFilter
    Redirects any non-HTTPS request to its HTTPS equivalent. Can be configured to use a ServerWebExchangeMatcher to narrow which requests get redirected. Can also be configured for custom ports using PortMapper.
    Since:
    5.1
    • Constructor Detail

      • HttpsRedirectWebFilter

        public HttpsRedirectWebFilter()
    • Method Detail

      • filter

        public reactor.core.publisher.Mono<java.lang.Void> filter​(org.springframework.web.server.ServerWebExchange exchange,
                                                                  org.springframework.web.server.WebFilterChain chain)
        Specified by:
        filter in interface org.springframework.web.server.WebFilter
      • setPortMapper

        public void setPortMapper​(PortMapper portMapper)
        Use this PortMapper for mapping custom ports
        Parameters:
        portMapper - the PortMapper to use
      • setRequiresHttpsRedirectMatcher

        public void setRequiresHttpsRedirectMatcher​(ServerWebExchangeMatcher requiresHttpsRedirectMatcher)
        Use this ServerWebExchangeMatcher to narrow which requests are redirected to HTTPS. The filter already first checks for HTTPS in the uri scheme, so it is not necessary to include that check in this matcher.
        Parameters:
        requiresHttpsRedirectMatcher - the ServerWebExchangeMatcher to use