Module methanol

Interface Methanol.Interceptor.Chain<T>

  • Type Parameters:
    T - the response body type
    Enclosing interface:
    Methanol.Interceptor

    public static interface Methanol.Interceptor.Chain<T>
    An object that gives interceptors the ability to relay requests to sibling interceptors, till eventually being sent by the client's backend.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.net.http.HttpResponse.BodyHandler<T> bodyHandler()
      Returns the BodyHandler this chain uses for handling the response.
      java.net.http.HttpResponse<T> forward​(java.net.http.HttpRequest request)
      Forwards the request to the next interceptor or to the client's backend if called by the last interceptor.
      java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>> forwardAsync​(java.net.http.HttpRequest request)
      Forwards the request to the next interceptor, or asynchronously to the client's backend if called by the last interceptor.
      java.util.Optional<java.net.http.HttpResponse.PushPromiseHandler<T>> pushPromiseHandler()
      Returns the PushPromiseHandler this chain uses for handling push promises.
      default <U> Methanol.Interceptor.Chain<U> with​(java.net.http.HttpResponse.BodyHandler<U> bodyHandler, @Nullable java.net.http.HttpResponse.PushPromiseHandler<U> pushPromiseHandler)
      Returns a new chain that uses given handlers, possibly targeting another response type.
      default Methanol.Interceptor.Chain<T> with​(java.util.function.UnaryOperator<java.net.http.HttpResponse.BodyHandler<T>> bodyHandlerTransformer)
      Returns a new chain after applying the given function to this chain's body handler.
      default Methanol.Interceptor.Chain<T> with​(java.util.function.UnaryOperator<java.net.http.HttpResponse.BodyHandler<T>> bodyHandlerTransformer, java.util.function.UnaryOperator<java.net.http.HttpResponse.PushPromiseHandler<T>> pushPromiseHandlerTransformer)
      Returns a new chain after applying the given functions to this chain's body and push promise handlers, and only to the latter if a push promise handler is present.
      Methanol.Interceptor.Chain<T> withBodyHandler​(java.net.http.HttpResponse.BodyHandler<T> bodyHandler)
      Returns a new chain that uses the given BodyHandler.
      Methanol.Interceptor.Chain<T> withPushPromiseHandler​(@Nullable java.net.http.HttpResponse.PushPromiseHandler<T> pushPromiseHandler)
      Returns a new chain that uses the given PushPromiseHandler.
    • Method Detail

      • bodyHandler

        java.net.http.HttpResponse.BodyHandler<T> bodyHandler()
        Returns the BodyHandler this chain uses for handling the response.
      • pushPromiseHandler

        java.util.Optional<java.net.http.HttpResponse.PushPromiseHandler<T>> pushPromiseHandler()
        Returns the PushPromiseHandler this chain uses for handling push promises.
      • withBodyHandler

        Methanol.Interceptor.Chain<T> withBodyHandler​(java.net.http.HttpResponse.BodyHandler<T> bodyHandler)
        Returns a new chain that uses the given BodyHandler.
      • withPushPromiseHandler

        Methanol.Interceptor.Chain<T> withPushPromiseHandler​(@Nullable java.net.http.HttpResponse.PushPromiseHandler<T> pushPromiseHandler)
        Returns a new chain that uses the given PushPromiseHandler.
      • with

        default <U> Methanol.Interceptor.Chain<U> with​(java.net.http.HttpResponse.BodyHandler<U> bodyHandler,
                                                       @Nullable java.net.http.HttpResponse.PushPromiseHandler<U> pushPromiseHandler)
        Returns a new chain that uses given handlers, possibly targeting another response type.
      • with

        default Methanol.Interceptor.Chain<T> with​(java.util.function.UnaryOperator<java.net.http.HttpResponse.BodyHandler<T>> bodyHandlerTransformer)
        Returns a new chain after applying the given function to this chain's body handler.
      • with

        default Methanol.Interceptor.Chain<T> with​(java.util.function.UnaryOperator<java.net.http.HttpResponse.BodyHandler<T>> bodyHandlerTransformer,
                                                   java.util.function.UnaryOperator<java.net.http.HttpResponse.PushPromiseHandler<T>> pushPromiseHandlerTransformer)
        Returns a new chain after applying the given functions to this chain's body and push promise handlers, and only to the latter if a push promise handler is present.
      • forward

        java.net.http.HttpResponse<T> forward​(java.net.http.HttpRequest request)
                                       throws java.io.IOException,
                                              java.lang.InterruptedException
        Forwards the request to the next interceptor or to the client's backend if called by the last interceptor.
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • forwardAsync

        java.util.concurrent.CompletableFuture<java.net.http.HttpResponse<T>> forwardAsync​(java.net.http.HttpRequest request)
        Forwards the request to the next interceptor, or asynchronously to the client's backend if called by the last interceptor.