Interface WebRouteManager<A extends ExchangeContext,B extends WebRouter<A>>

Type Parameters:
A - the exchange context type
B - the Web router type
All Superinterfaces:
BaseWebRouteManager<A,WebExchange<A>,WebRoute<A>,B>

public interface WebRouteManager<A extends ExchangeContext,B extends WebRouter<A>> extends BaseWebRouteManager<A,WebExchange<A>,WebRoute<A>,B>

Manages Web routes in the Web server.

A Web route manager is obtained from WebServer.route(), it allows to specify the criteria a Web exchange must match to be handled by the Web exchange handler defined in handler(ExchangeHandler).

When setting the exchange handler, interceptors defined in an intercepted Web server are applied to the route when criteria are matching.

It is possible to specify multiple values for any given criteria resulting in multiple Web routes being created in the Web router. For instance, the following code will result in the creation of two routes:


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

    • path

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

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

      The specified 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 route manager
      Throws:
      IllegalArgumentException - if the specified path is not absolute
    • path

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

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

      The specified 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 route manager
      Throws:
      IllegalArgumentException - if the specified path is not absolute
    • method

      WebRouteManager<A,B> method(Method method)

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

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

      WebRouteManager<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 exchange to be processed by the route.

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

      WebRouteManager<A,B> produce(String mediaType)

      Specifies the media type as defined by RFC 7231 Section 5.3.2 that must be accepted by a Web exchange to be processed by the route.

      Parameters:
      mediaType - a media type
      Returns:
      the route manager
    • language

      WebRouteManager<A,B> language(String languageTag)

      Specifies the language tag as defined by RFC 7231 Section 5.3.5 that must be accepted by a Web exchange to be processed by the route.

      Parameters:
      languageTag - a language tag (e.g. fr-FR)
      Returns:
      the route manager
    • handler

      B handler(ExchangeHandler<? super A,WebExchange<A>> handler)

      Specifies the Web exchange handler used to process Web exchanges matching the criteria specified in the route manager and returns the originating Web router.

      The Web route manager is usually obtained from WebServer.route() in which case the resulting Web router is then a WebServer instance.

      Any Web route interceptor defined in an intercepted Web server and matching the criteria specified in the route manager is applied to the resulting Web routes.

      Parameters:
      handler - a Web exchange handler
      Returns:
      the originating Web router