- java.lang.Object
-
- io.github.nstdio.http.ext.BodyPublishers
-
public final class BodyPublishers extends java.lang.Object
Implementations of various usefulHttpRequest.BodyPublisher
s.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.net.http.HttpRequest.BodyPublisher
ofJson(java.lang.Object body)
Returns a request body publisher whose body is JSON representation ofbody
.static java.net.http.HttpRequest.BodyPublisher
ofJson(java.lang.Object body, JsonMappingProvider jsonProvider)
Returns a request body publisher whose body is JSON representation ofbody
.static java.net.http.HttpRequest.BodyPublisher
ofJson(java.lang.Object body, JsonMappingProvider jsonProvider, java.util.concurrent.Executor executor)
Returns a request body publisher whose body is JSON representation ofbody
.static java.net.http.HttpRequest.BodyPublisher
ofJson(java.lang.Object body, java.util.concurrent.Executor executor)
Returns a request body publisher whose body is JSON representation ofbody
.
-
-
-
Method Detail
-
ofJson
public static java.net.http.HttpRequest.BodyPublisher ofJson(java.lang.Object body)
Returns a request body publisher whose body is JSON representation ofbody
. The conversion will be done usingJsonMappingProvider
default provider retrieved usingJsonMappingProvider.provider()
.- Parameters:
body
- The body.- Returns:
- a BodyPublisher
-
ofJson
public static java.net.http.HttpRequest.BodyPublisher ofJson(java.lang.Object body, JsonMappingProvider jsonProvider)
Returns a request body publisher whose body is JSON representation ofbody
. The conversion will be done usingjsonProvider
.- Parameters:
body
- The body.jsonProvider
- The JSON mapping provider to use when creating JSON presentation ofbody
.- Returns:
- a BodyPublisher
-
ofJson
public static java.net.http.HttpRequest.BodyPublisher ofJson(java.lang.Object body, java.util.concurrent.Executor executor)
Returns a request body publisher whose body is JSON representation ofbody
. The conversion will be done usingJsonMappingProvider
default provider retrieved usingJsonMappingProvider.provider()
.- Parameters:
body
- The body.executor
- The scheduler to use to publish body to subscriber. Ifnull
the *ForkJoinPool.commonPool()
will be used.- Returns:
- a BodyPublisher
-
ofJson
public static java.net.http.HttpRequest.BodyPublisher ofJson(java.lang.Object body, JsonMappingProvider jsonProvider, java.util.concurrent.Executor executor)
Returns a request body publisher whose body is JSON representation ofbody
. The conversion will be done * usingjsonProvider
.- Parameters:
body
- The body.jsonProvider
- The JSON mapping provider to use when creating JSON presentation ofbody
.executor
- The scheduler to use to publish body to subscriber. Ifnull
theForkJoinPool.commonPool()
will be used.- Returns:
- a BodyPublisher
-
-