public interface PayloadHandler
Modifier and Type | Method and Description |
---|---|
com.google.gson.JsonElement |
getPayloadAsJson()
Gets the payload as JSON
|
<T> T |
processAndUpdatePayload(String encoding,
BiFunction<InputStream,String,T> processingFunction)
This method can be used for complex scenarios like Encryption/Decryption,
Passthrough or where
InputStream has to be read in a different way. |
void |
updatePayloadAsJson(com.google.gson.JsonElement updatedJsonPayload)
Updates the middleware with updated payload as JSON
|
com.google.gson.JsonElement getPayloadAsJson()
JsonElement
void updatePayloadAsJson(com.google.gson.JsonElement updatedJsonPayload)
updatedJsonPayload
- The updated payload as JSONJsonElement
<T> T processAndUpdatePayload(String encoding, BiFunction<InputStream,String,T> processingFunction)
This method can be used for complex scenarios like Encryption/Decryption,
Passthrough or where InputStream
has to be read in a different way.
Provided BiFuntion will be applied with InputStream
, encoding and
its result will be stored by middleware which will be propagated further in
the pipeline.
BiFunction example to process stream and return Json
(stream, encoding) -> {
// Logic to update incoming stream
JsonElement json = customLogicToConvertStreamToJson();
// Update resultant Json based on requirement
// Finally return the updated Json
return json;
}
Similarly one can return InputStream
or String
based on
their requirement
encoding
- The character encoding that should be used in
BiFunction
for stream conversions. If found null then
UTF-8 will be used by default.processingFunction
- A BiFunction
that takes
InputStream
and encoding as input and returns T which will
be consumed by middleware where T can be either JsonElement,
InputStream or String.JsonElement
, InputStream
or String
BiFunction
Copyright © 2019. All rights reserved.