Package io.servicetalk.http.api
Class HttpSerializationProviders
- java.lang.Object
-
- io.servicetalk.http.api.HttpSerializationProviders
-
public final class HttpSerializationProviders extends java.lang.ObjectA factory to createHttpSerializationProviders.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>formUrlEncodedDeserializer()Creates anHttpDeserializerthat can deserialize key-valuesMaps withStandardCharsets.UTF_8from urlencoded forms.static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>formUrlEncodedDeserializer(java.nio.charset.Charset charset)Creates anHttpDeserializerthat can deserialize key-valuesMaps withStandardCharsets.UTF_8from urlencoded forms.static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>formUrlEncodedDeserializer(java.nio.charset.Charset charset, java.util.function.Predicate<HttpHeaders> checkContentType)Creates anHttpDeserializerthat can deserialize key-valuesMaps withStandardCharsets.UTF_8from urlencoded forms.static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>formUrlEncodedSerializer()Creates anHttpSerializerthat can serialize a key-valuesMaps withStandardCharsets.UTF_8Charsetto urlencoded forms.static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>formUrlEncodedSerializer(java.nio.charset.Charset charset)Creates anHttpSerializerthat can serialize key-valuesMaps with the specifiedCharsetto to urlencoded forms.static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>>formUrlEncodedSerializer(java.nio.charset.Charset charset, java.util.function.Consumer<HttpHeaders> addContentType)Creates anHttpSerializerthat can serialize a key-valuesMaps with the specifiedCharsetto urlencoded forms.static HttpSerializationProviderjsonSerializer(SerializationProvider serializationProvider)Creates a newHttpSerializationProviderthat could serialize/deserialize to/from JSON using the passedSerializationProvider.static HttpSerializationProviderjsonSerializer(Serializer serializer)Creates a newHttpSerializationProviderthat could serialize/deserialize to/from JSON using the passedSerializer.static HttpSerializationProviderserializationProvider(SerializationProvider serializationProvider, java.util.function.Consumer<HttpHeaders> addContentType, java.util.function.Predicate<HttpHeaders> checkContentType)Creates a newHttpSerializationProviderthat could serialize/deserialize to/from the desired content-type using the passedSerializationProvider.static HttpSerializationProviderserializationProvider(Serializer serializer, java.util.function.Consumer<HttpHeaders> addContentType, java.util.function.Predicate<HttpHeaders> checkContentType)Creates a newHttpSerializationProviderthat could serialize/deserialize to/from the desired content-type using the passedSerializer.static HttpDeserializer<java.lang.String>textDeserializer()static HttpDeserializer<java.lang.String>textDeserializer(java.nio.charset.Charset charset)static HttpDeserializer<java.lang.String>textDeserializer(java.nio.charset.Charset charset, java.util.function.Predicate<HttpHeaders> checkContentType)static HttpSerializer<java.lang.String>textSerializer()static HttpSerializer<java.lang.String>textSerializer(java.nio.charset.Charset charset)static HttpSerializer<java.lang.String>textSerializer(java.nio.charset.Charset charset, java.util.function.Consumer<HttpHeaders> addContentType)
-
-
-
Method Detail
-
formUrlEncodedSerializer
public static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedSerializer()
Creates anHttpSerializerthat can serialize a key-valuesMaps withStandardCharsets.UTF_8Charsetto urlencoded forms.- Returns:
HttpSerializerthat could serialize key-valueMap.- See Also:
- x-www-form-urlencoded specification
-
formUrlEncodedSerializer
public static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedSerializer(java.nio.charset.Charset charset)
Creates anHttpSerializerthat can serialize key-valuesMaps with the specifiedCharsetto to urlencoded forms.- Parameters:
charset-Charsetfor the key-valueMapthat will be serialized.- Returns:
HttpSerializerthat could serialize from key-valueMap.- See Also:
- x-www-form-urlencoded specification
-
formUrlEncodedSerializer
public static HttpSerializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedSerializer(java.nio.charset.Charset charset, java.util.function.Consumer<HttpHeaders> addContentType)
Creates anHttpSerializerthat can serialize a key-valuesMaps with the specifiedCharsetto urlencoded forms.- Parameters:
charset-Charsetfor the key-valueMapthat will be serialized.addContentType- AConsumerthat adds relevant headers to the passedHttpHeadersmatching the serialized payload. Typically, this involves adding aHttpHeaderNames.CONTENT_TYPEheader.- Returns:
HttpSerializerthat could serialize from key-valueMap.- See Also:
- x-www-form-urlencoded specification
-
formUrlEncodedDeserializer
public static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedDeserializer()
Creates anHttpDeserializerthat can deserialize key-valuesMaps withStandardCharsets.UTF_8from urlencoded forms.- Returns:
HttpDeserializerthat could deserialize a key-valuesMap.- See Also:
- x-www-form-urlencoded specification
-
formUrlEncodedDeserializer
public static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedDeserializer(java.nio.charset.Charset charset)
Creates anHttpDeserializerthat can deserialize key-valuesMaps withStandardCharsets.UTF_8from urlencoded forms.- Parameters:
charset-Charsetfor the key-valueMapthat will be deserialized. deserialized payload. If the validation fails, then deserialization will fail withSerializationException- Returns:
HttpDeserializerthat could deserialize a key-valueMap.- See Also:
- x-www-form-urlencoded specification
-
formUrlEncodedDeserializer
public static HttpDeserializer<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> formUrlEncodedDeserializer(java.nio.charset.Charset charset, java.util.function.Predicate<HttpHeaders> checkContentType)
Creates anHttpDeserializerthat can deserialize key-valuesMaps withStandardCharsets.UTF_8from urlencoded forms.- Parameters:
charset-Charsetfor the key-valueMapthat will be deserialized.checkContentType- Checks theHttpHeadersto see if a compatible encoding is found. deserialized payload. If the validation fails, then deserialization will fail withSerializationException- Returns:
HttpDeserializerthat could deserialize a key-valueMap.- See Also:
- x-www-form-urlencoded specification
-
textSerializer
public static HttpSerializer<java.lang.String> textSerializer()
- Returns:
HttpSerializerthat could serializeString.
-
textSerializer
public static HttpSerializer<java.lang.String> textSerializer(java.nio.charset.Charset charset)
- Parameters:
charset-Charsetfor theStringthat will be serialized.- Returns:
HttpSerializerthat could serialize fromString.
-
textSerializer
public static HttpSerializer<java.lang.String> textSerializer(java.nio.charset.Charset charset, java.util.function.Consumer<HttpHeaders> addContentType)
- Parameters:
charset-Charsetfor theStringthat will be serialized.addContentType- AConsumerthat adds relevant headers to the passedHttpHeadersmatching the serialized payload. Typically, this involves adding aHttpHeaderNames.CONTENT_TYPEheader.- Returns:
HttpSerializerthat could serialize fromString.
-
textDeserializer
public static HttpDeserializer<java.lang.String> textDeserializer()
- Returns:
HttpDeserializerthat could deserializeString.
-
textDeserializer
public static HttpDeserializer<java.lang.String> textDeserializer(java.nio.charset.Charset charset)
- Parameters:
charset-Charsetfor theStringthat will be deserialized.- Returns:
HttpDeserializerthat could deserializeString.
-
textDeserializer
public static HttpDeserializer<java.lang.String> textDeserializer(java.nio.charset.Charset charset, java.util.function.Predicate<HttpHeaders> checkContentType)
- Parameters:
charset-Charsetfor theStringthat will be deserialized.checkContentType- APredicatethat validates the passedHttpHeadersas expected for the deserialized payload. If the validation fails, then deserialization will fail withSerializationException- Returns:
HttpDeserializerthat could deserializeString.
-
jsonSerializer
public static HttpSerializationProvider jsonSerializer(Serializer serializer)
Creates a newHttpSerializationProviderthat could serialize/deserialize to/from JSON using the passedSerializer. For serialization, the returnedHttpSerializationProvideradds aHttpHeaderNames.CONTENT_TYPEheader with valueHttpHeaderValues.APPLICATION_JSON. For deserialization, it expects aHttpHeaderNames.CONTENT_TYPEheader with valueHttpHeaderValues.APPLICATION_JSON. If the expected header is not present, then deserialization will fail withSerializationException.- Parameters:
serializer-Serializerthat has the capability of serializing/deserializing to/from JSON.- Returns:
HttpSerializationProviderthat has the capability of serializing/deserializing to/from JSON.
-
jsonSerializer
public static HttpSerializationProvider jsonSerializer(SerializationProvider serializationProvider)
Creates a newHttpSerializationProviderthat could serialize/deserialize to/from JSON using the passedSerializationProvider. For serialization, the returnedHttpSerializationProvideradds aHttpHeaderNames.CONTENT_TYPEheader with valueHttpHeaderValues.APPLICATION_JSON. For deserialization, it expects aHttpHeaderNames.CONTENT_TYPEheader with valueHttpHeaderValues.APPLICATION_JSON. If the expected header is not present, then deserialization will fail withSerializationException.- Parameters:
serializationProvider-SerializationProviderthat has the capability of serializing/deserializing to/from JSON.- Returns:
HttpSerializationProviderthat has the capability of serializing/deserializing to/from JSON.
-
serializationProvider
public static HttpSerializationProvider serializationProvider(Serializer serializer, java.util.function.Consumer<HttpHeaders> addContentType, java.util.function.Predicate<HttpHeaders> checkContentType)
Creates a newHttpSerializationProviderthat could serialize/deserialize to/from the desired content-type using the passedSerializer.For serialization, the returned
HttpSerializationProviderwould updateHttpHeadersappropriately to indicate the content-type using the passedaddContentType.For deserialization, it would validate headers as specified by the passed
checkContentType predicate. If the validation fails, then deserialization will fail withSerializationException.- Parameters:
serializer-Serializerthat has the capability of serializing/deserializing to/from a desired content-type.addContentType- AConsumerthat adds relevant headers to the passedHttpHeadersmatching the serialized payload. Typically, this involves adding aHttpHeaderNames.CONTENT_TYPEheader.checkContentType- APredicatethat validates the passedHttpHeadersas expected for the deserialized payload. If the validation fails, then deserialization will fail withSerializationException- Returns:
HttpSerializationProviderthat has the capability of serializing/deserializing to/from a desired content-type.
-
serializationProvider
public static HttpSerializationProvider serializationProvider(SerializationProvider serializationProvider, java.util.function.Consumer<HttpHeaders> addContentType, java.util.function.Predicate<HttpHeaders> checkContentType)
Creates a newHttpSerializationProviderthat could serialize/deserialize to/from the desired content-type using the passedSerializationProvider.For serialization, the returned
HttpSerializationProviderwould updateHttpHeadersappropriately to indicate the content-type using the passedaddContentType.For deserialization, it would validate headers as specified by the passed
checkContentType predicate. If the validation fails, then deserialization will fail withSerializationException.- Parameters:
serializationProvider-SerializationProviderthat has the capability of serializing/deserializing to/from a desired content-type.addContentType- AConsumerthat adds relevant headers to the passedHttpHeadersmatching the serialized payload. Typically, this involves adding aHttpHeaderNames.CONTENT_TYPEheader.checkContentType- APredicatethat validates the passedHttpHeadersas expected for the deserialized payload. If the validation fails, then deserialization will fail withSerializationException.- Returns:
HttpSerializationProviderthat has the capability of serializing/deserializing to/from a desired content-type.
-
-