Package com.styra.opa.openapi.utils
Class Helpers
java.lang.Object
com.styra.opa.openapi.utils.Helpers
Public helper methods for use by customers and end-users.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]bodyBytes(HttpRequest request) Returns the request body as a byte array.static StringbodyUtf8(HttpRequest request) Returns the request body as a String assuming that the bytes of the request body are encoded with UTF-8.static HttpRequest.Buildercopy(HttpRequest request) Returns anHttpRequest.Builderwhich is initialized with the state of the givenHttpRequest.static HttpRequest.Buildercopy(HttpRequest request, BiPredicate<String, String> filter) Returns anHttpRequest.Builderwhich is initialized with the state of the givenHttpRequest.
-
Constructor Details
-
Helpers
public Helpers()
-
-
Method Details
-
copy
Returns anHttpRequest.Builderwhich is initialized with the state of the givenHttpRequest.Note that headers can be added and modified but not removed. To remove headers use
copy(HttpRequest, BiPredicate)(which applies a filter to the headers while copying).Note also that this method is redundant from JDK 16 because the method
HttpRequest.newBuilder(HttpRequest)is available.- Parameters:
request- request to copy- Returns:
- a builder initialized with values from
request
-
copy
Returns anHttpRequest.Builderwhich is initialized with the state of the givenHttpRequest.Note that this method is redundant from JDK 16 because the method
HttpRequest.newBuilder(HttpRequest, BiPredicate)is available.- Parameters:
request- request to copyfilter- selects which header key-values to include in the copied request- Returns:
- a builder initialized with values from
request
-
bodyBytes
Returns the request body as a byte array.- Parameters:
request- http request to extract from- Returns:
- byte array
-
bodyUtf8
Returns the request body as a String assuming that the bytes of the request body are encoded with UTF-8.- Parameters:
request- http request to extract from- Returns:
- request body as a String
-