vibe.d beta banner
get vibe.d
0.10.1

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

Function viaHeader

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

WebParamAttribute viaHeader (
  string field
) @safe;

If the parameter is a string, or any scalar type (float, int, char[], ...), it will be send as a string. If it's an aggregate, it will be serialized as JSON. However, passing aggregate via header isn't a good practice and should be avoided for new production code.

There are currently two kinds of symbol to do this: viaHeader and headerParam. viaHeader should be applied to the parameter itself, while headerParam is applied to the function. headerParam 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 header field to use (e.g: 'Accept', 'Content-Type'...). ---- // The server will receive the content of the "Authorization" header. void login(@viaHeader("Authorization") string auth); ----
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.