Package com.styra.opa.openapi.utils
Interface Hook.BeforeRequest
-
- All Known Implementing Classes:
Hook.IdempotencyHook
,Hooks
- Enclosing class:
- Hook
public static interface Hook.BeforeRequest
Specifies how a request is transformed before sending.
-
-
Field Summary
Fields Modifier and Type Field Description static Hook.BeforeRequest
DEFAULT
The default action is to return the request untouched.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.net.http.HttpRequest
beforeRequest(Hook.BeforeRequestContext context, java.net.http.HttpRequest request)
Transforms the givenHttpRequest
before sending.
-
-
-
Field Detail
-
DEFAULT
static final Hook.BeforeRequest DEFAULT
The default action is to return the request untouched.
-
-
Method Detail
-
beforeRequest
java.net.http.HttpRequest beforeRequest(Hook.BeforeRequestContext context, java.net.http.HttpRequest request) throws java.lang.Exception
Transforms the givenHttpRequest
before sending.Note that
HttpRequest
is immutable. To modify the request you can useHttpRequest#newBuilder(HttpRequest, BiPredicate
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 callrequest
- request to be transformed- Returns:
- transformed request
- Throws:
java.lang.Exception
- on error
-
-