Interface AsyncHook.BeforeRequest

  • All Known Implementing Classes:
    AsyncHook.IdempotencyHook, AsyncHooks
    Enclosing class:
    AsyncHook
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public static interface AsyncHook.BeforeRequest
    Specifies how a request is transformed before sending.
    • Method Detail

      • beforeRequest

        java.util.concurrent.CompletableFuture<java.net.http.HttpRequest> beforeRequest​(Hook.BeforeRequestContext context,
                                                                                        java.net.http.HttpRequest request)
        Transforms the given HttpRequest before sending.

        Note that HttpRequest is immutable. To modify the request you can use HttpRequest#newBuilder(HttpRequest, BiPredicate<String, String>) with JDK 16 and later (which will copy the request for modification in a builder). If that method is not available then use Helpers.copy(java.net.http.HttpRequest) (which also returns a builder).

        Parameters:
        context - context for the hook call
        request - request to be transformed
        Returns:
        transformed request