bodyParam

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.

  1. WebParamAttribute bodyParam(string identifier, string field)
    @safe
    bodyParam
    (
    string identifier
    ,
    string field
    )
  2. WebParamAttribute bodyParam(string identifier)

Parameters

identifier string

The name of the parameter to customize. A compiler error will be issued on mismatch.

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