Class ProtobufRequestConverterFunction
java.lang.Object
com.linecorp.armeria.server.protobuf.ProtobufRequestConverterFunction
- All Implemented Interfaces:
com.linecorp.armeria.server.annotation.RequestConverterFunction
@UnstableApi
public final class ProtobufRequestConverterFunction
extends Object
implements com.linecorp.armeria.server.annotation.RequestConverterFunction
A
RequestConverterFunction which converts a Protocol Buffers or JSON body of
the AggregatedHttpRequest to an object.
The built-in parser of Message for Protocol Buffers is applied only when the content-type of
RequestHeaders is either one of MediaType.PROTOBUF or MediaType.OCTET_STREAM or
the MediaType.subtype() contains "protobuf".
The JsonFormat.Parser for JSON is applied only when the content-type of
the RequestHeaders is either MediaType.JSON or ends with +json.
Conversion of multiple Protobuf messages
A sequence of Protocol Buffer messages can not be handled by thisRequestConverterFunction,
because Protocol Buffers wire format is not self-delimiting.
See
Streaming Multiple Messages
for more information.
However, Collection types such as List<Message> and Set<Message> are supported
when converted from JSON array.
Note that this RequestConverterFunction is applied to an annotated service by default,
so you don't have to specify this converter explicitly unless you want to use your own JsonFormat.Parser and
ExtensionRegistry.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance with the defaultJsonFormat.ParserandExtensionRegistry.ProtobufRequestConverterFunction(JsonFormat.Parser jsonParser, ExtensionRegistry extensionRegistry) Creates an instance with the specifiedJsonFormat.ParserandExtensionRegistry. -
Method Summary
Modifier and TypeMethodDescription@Nullable ObjectconvertRequest(com.linecorp.armeria.server.ServiceRequestContext ctx, com.linecorp.armeria.common.AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType)
-
Constructor Details
-
ProtobufRequestConverterFunction
public ProtobufRequestConverterFunction()Creates an instance with the defaultJsonFormat.ParserandExtensionRegistry. -
ProtobufRequestConverterFunction
public ProtobufRequestConverterFunction(JsonFormat.Parser jsonParser, ExtensionRegistry extensionRegistry) Creates an instance with the specifiedJsonFormat.ParserandExtensionRegistry.
-
-
Method Details
-
convertRequest
@Nullable public @Nullable Object convertRequest(com.linecorp.armeria.server.ServiceRequestContext ctx, com.linecorp.armeria.common.AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable @Nullable ParameterizedType expectedParameterizedResultType) throws Exception - Specified by:
convertRequestin interfacecom.linecorp.armeria.server.annotation.RequestConverterFunction- Throws:
Exception
-