Expand description
Smithy RPC v2 CBOR (smithy.protocols#rpcv2Cbor) wire support.
An rpcv2Cbor request is POST /service/{ServiceName}/operation/{Operation}
with the smithy-protocol: rpc-v2-cbor header and a CBOR-encoded input
structure as the body. Responses carry the same header, Content-Type: application/cbor, and a CBOR body; errors are a CBOR map holding __type
plus the error structure’s members.
fakecloud’s JSON-protocol handlers already take a JSON input document, so
the dispatcher decodes the CBOR body into the equivalent awsJson document
(decode_to_json: tag-1 timestamps become epoch seconds, byte strings
become base64 strings) and routes the request through the service’s JSON
path. A service that knows its output schema returns a ready CBOR body
(content type CBOR_CONTENT_TYPE); any JSON response is transcoded
generically with json_to_cbor.
Enums§
- Cbor
Value - A representation of a dynamic CBOR value that can handled dynamically
Constants§
- CBOR_
CONTENT_ TYPE Content-Typeof every rpcv2Cbor request and response body.- RPC_
V2_ CBOR - Value of
SMITHY_PROTOCOL_HEADERfor rpcv2Cbor. - SMITHY_
PROTOCOL_ HEADER - Header naming the Smithy protocol on rpcv2Cbor requests and responses.
Functions§
- decode_
to_ json - Decode an rpcv2Cbor request body into the awsJson document a JSON handler reads. An empty body is an empty input structure.
- encode
- Encode a CBOR value to bytes, with definite lengths and every float as a
64-bit double. (A generic encoder shrinks floats to half/single precision
when lossless, but SDK decoders built without half-float support reject a
16-bit float where the schema says
double.) - error_
body - The CBOR body of an rpcv2Cbor error:
__typenames the error,messagecarries its text, and any extra members are added alongside (parsed as JSON when they hold a JSON document, as for the awsJson error body). - json_
to_ cbor - Schema-less transcoding of an awsJson document into CBOR, for services that do not render CBOR themselves: integers stay integers, other numbers become floats, strings stay text. Timestamps and blobs keep their awsJson form (number / base64 text) since their shape type is not known here.
- parse_
rpc_ v2_ path - Split an rpcv2Cbor request path
/service/{ServiceName}/operation/{Operation}into(ServiceName, Operation). Smithy allows a path prefix before/service/, so the match is anchored on the trailing four segments. - timestamp
- An epoch-seconds timestamp as rpcv2Cbor encodes it: tag 1 over a double. A float (rather than an integer for whole seconds) keeps millisecond precision and is what every SDK’s decoder accepts.