viaBody

Declare that a parameter will be transmitted to the API through the body.

It will be serialized as part of a JSON object. The serialization format is currently not customizable. If no fieldname is given, the entire body is serialized into the object.

There are currently two kinds of symbol to do this: viaBody and bodyParam. viaBody should be applied to the parameter itself, while bodyParam is applied to the function. bodyParam was introduced long before the D language for UDAs on parameters (introduced in DMD v2.082.0), and will be deprecated in a future release.

@safe
viaBody
(
string field = null
)

Parameters

field string

The name of the field in the JSON object.

void ship(@viaBody("package") int pack);
// The server will receive the following body for a call to ship(42):
// { "package": 42 }

Meta