Interface WebRouteInterceptorManager<A extends ExchangeContext,B extends WebRouteInterceptor<A>>

Type Parameters:
A - the exchange context type
B - the Web route interceptor type

public interface WebRouteInterceptorManager<A extends ExchangeContext,B extends WebRouteInterceptor<A>>

Defines Web route interceptors and creates decorated Web clients intercepting Web exchanges.

A Web route interceptor manager is obtained from WebClient.intercept() or more generally WebRouteInterceptor.intercept(), it allows to specify the criteria a Web exchange must match to be intercepted by the exchange interceptors defined in interceptor(ExchangeInterceptor) or interceptors(List). These methods return the intercepted Web client which shall be used to process Web exchanges intercepted when they are matching the defined criteria.

It is possible to specify multiple values for any given criteria resulting in multiple Web route interceptor definitions being created in the resulting Web route interceptor. For instance, the following code will result in two definitions being created:


 webClient
     .intercept()
         .uri(uri -> uri
             .scheme("http")
             .host("example.org")
             .path("/**")
         )
         .method(Method.GET)
         .method(Method.POST)
         .interceptor(exchange -> {...})
 
Since:
1.12
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • uri

      Specifies the URI that must be matched by a Web exchange to be intercepted.

      Parameters:
      uriConfigurer - a URI configurer
      Returns:
      the interceptor manager
    • method

      Specifies the HTTP method that must be matched by a Web route to be intercepted.

      Parameters:
      method - an HTTP method
      Returns:
      the interceptor manager
    • consume

      WebRouteInterceptorManager<A,B> consume(String mediaRange)

      Specifies the media range as defined by RFC 7231 Section 5.3.2 matching the content types consumed (i.e. accepted) by a Web exchange to be intercepted.

      Parameters:
      mediaRange - a media range (e.g. application/*)
      Returns:
      the interceptor manager
    • produce

      WebRouteInterceptorManager<A,B> produce(String mediaRange)

      Specifies the media range as defined by RFC 7231 Section 5.3.2 defining the content types produced by a Web exchange to be intercepted.

      Parameters:
      mediaRange - a media range (e.g. application/*)
      Returns:
      the interceptor manager
    • language

      WebRouteInterceptorManager<A,B> language(String languageRange)

      Specifies the language range as defined by RFC 7231 Section 5.3.5 matching the language consumed (i.e. accepted) by a Web exchange to be intercepted.

      Parameters:
      languageRange - a language range (e.g. *-FR)
      Returns:
      the interceptor manager
    • interceptor

      B interceptor(ExchangeInterceptor<? super A,InterceptedWebExchange<A>> interceptor)

      Specifies the Web exchange interceptor to apply to a Web exchange matching the criteria specified in the route manager and returns a Web route interceptor containing the interceptor definitions specified in the interceptor manager.

      The Web route interceptor manager is usually obtained from WebClient.intercept() in which case the resulting Web route interceptor is a WebClient.Intercepted instance.

      Parameters:
      interceptor - a Web exchange interceptor
      Returns:
      a new Web route interceptor containing one or more interceptor definitions
    • interceptors

      B interceptors(List<? extends ExchangeInterceptor<? super A,InterceptedWebExchange<A>>> interceptors)

      Specifies a list of Web exchange interceptors to apply to a Web exchange matching the criteria specified in the route manager and returns a Web route interceptor containing the interceptor definitions specified in the interceptor manager.

      The Web route interceptor manager is usually obtained from WebClient.intercept() in which case the resulting Web route interceptor is a WebClient.Intercepted instance.

      Parameters:
      interceptors - a list of Web exchange interceptors
      Returns:
      a new Web route interceptor containing one or more interceptor definitions