vibe.d beta banner
get vibe.d
0.10.0

Asynchronous I/O that doesn’t get in your way, written in D

Function bodyParam

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

WebParamAttribute bodyParam (
  string identifier,
  string field
) @safe;

WebParamAttribute bodyParam (
  string identifier
) @safe;

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.

Parameters

NameDescription
identifier The name of the parameter to customize. A compiler error will be issued on mismatch.
field 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 } ----
Authors

Sönke Ludwig, Михаил Страшун

Copyright

© 2012-2017 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.