vibe.d beta banner
get vibe.d

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

Function queryParam

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

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

It will be serialized as part of a JSON object, and will go through URL serialization. The serialization format is not customizable.

There are currently two kinds of symbol to do this: viaQuery and queryParam. viaQuery should be applied to the parameter itself, while queryParam is applied to the function. queryParam 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.


identifier The name of the parameter to customize. A compiler error will be issued on mismatch.
field The field name to use. ---- // For a call to postData("D is awesome"), the server will receive the query: // POST /data?test=%22D is awesome%22 void postData(@viaQuery("test") string data); ----

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


© 2012-2017 Sönke Ludwig


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