- java.lang.Object
-
- io.github.nstdio.http.ext.BodyPublishers
-
public final class BodyPublishers extends java.lang.ObjectImplementations of various usefulHttpRequest.BodyPublishers.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.net.http.HttpRequest.BodyPublisherofJson(java.lang.Object body)Returns a request body publisher whose body is JSON representation ofbody.static java.net.http.HttpRequest.BodyPublisherofJson(java.lang.Object body, JsonMappingProvider jsonProvider)Returns a request body publisher whose body is JSON representation ofbody.static java.net.http.HttpRequest.BodyPublisherofJson(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.BodyPublisherofJson(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 usingJsonMappingProviderdefault 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 usingJsonMappingProviderdefault provider retrieved usingJsonMappingProvider.provider().- Parameters:
body- The body.executor- The scheduler to use to publish body to subscriber. Ifnullthe *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. IfnulltheForkJoinPool.commonPool()will be used.- Returns:
- a BodyPublisher
-
-