Interface WebExchange<A extends ExchangeContext>

Type Parameters:
A - the type of the exchange context
All Superinterfaces:
BaseExchange<A,Request,Response>, Exchange<A>

public interface WebExchange<A extends ExchangeContext> extends Exchange<A>

An exchange that extends the HTTP server Exchange with features for the Web.

It supports request body decoding based on the request content type as well as response body encoding based on the response content type.

It also gives access to path parameters when processed in a route defined with a URIPattern.

It also exposes a context which can be used to propagate information in a chain of exchange handlers. The WebRouter uses WebServerControllerConfigurer.createContext() to create the context attached to the Web exchange.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Method Details

    • request

      WebRequest request()
      Description copied from interface: BaseExchange

      Returns the request part of the exchange.

      Specified by:
      request in interface BaseExchange<A extends ExchangeContext,Request,Response>
      Returns:
      the request part
    • response

      WebResponse response()
      Description copied from interface: BaseExchange

      Returns the response part of the exchange.

      Specified by:
      response in interface BaseExchange<A extends ExchangeContext,Request,Response>
      Returns:
      the response part
    • webSocket

      Optional<? extends WebSocket<A,Web2SocketExchange<A>>> webSocket(String... subProtocols)
      Description copied from interface: Exchange

      Upgrades the exchange to a WebSocket exchange.

      If the exchange cannot upgrade to the WebSocket protocol, an empty optional shall be returned. For instance, if the state of the exchange prevents the upgrade (e.g. error exchange) or if the underlying HTTP protocol does not support the upgrade operation. Currently only HTTP/1.1 can upgrade to the WebSocket protocol.

      Specified by:
      webSocket in interface Exchange<A extends ExchangeContext>
      Parameters:
      subProtocols - a list of supported subprotocols negotiated during the handshake
      Returns:
      an optional returning the WebSocket or an empty optional if the upgrade is not possible