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 servers intercepting Web routes.

A Web route interceptor manager is obtained from WebServer.intercept() or more generally WebRouteInterceptor.intercept(), it allows to specify the criteria a Web route must match to be intercepted by the exchange interceptors defined in interceptor(ExchangeInterceptor) or interceptors(List). These methods return the intercepted Web server which shall be used to define Web routes 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:


 webServer
     .intercept()
         .path("/path/to/resource")
         .method(Method.GET)
         .method(Method.POST)
         .interceptor(exchange -> {...})
 
Since:
1.12
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • path

      default WebRouteInterceptorManager<A,B> path(String path)

      Specifies the absolute path that must be matched by a Web route to be intercepted.

      The path can be specified as a parameterized path and include path pattern like ?, *, ** as defined by URIBuilder. Note that this path is only meant to filter routes and as a result path parameters have no use.

      Parameters:
      path - a path
      Returns:
      the interceptor manager
      Throws:
      IllegalArgumentException - if the specified path is not absolute
    • path

      WebRouteInterceptorManager<A,B> path(String path, boolean matchTrailingSlash)

      Specifies the absolute path that must be matched with or without trailing slash by a Web route to be intercepted.

      The path can be specified as a parameterized path and include path pattern like ?, *, ** as defined by URIBuilder. Note that this path is only meant to filter routes and as a result path parameters have no use.

      Parameters:
      path - a path
      matchTrailingSlash - true to match path with or without trailing slash, false otherwise
      Returns:
      the interceptor manager
      Throws:
      IllegalArgumentException - if the specified path is not absolute
    • 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 defining the content types accepted by a Web route 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 matching the content type produced by a Web route 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 produced by a Web route to be intercepted.

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

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

      Specifies the Web exchange interceptor to apply to a Web route 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 WebServer.intercept() in which case the resulting Web route interceptor is a WebServer.Intercepted instance.

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

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

      Specifies a list of Web exchange interceptors to apply to a Web route 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 WebServer.intercept() in which case the resulting Web route interceptor is a WebServer.Intercepted instance.

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