Helper to get a required or default-valued request argument.
Declared in <rpc/util.h>
template<typename R>
auto
Arg(std::string_view key) const;
Use this function when the argument is required or when it has a default value. If the argument is optional and may not be provided, use MaybeArg instead.
This function only works during m_fun(), i.e., it should only be used in RPC method implementations. It internally checks whether the user-passed argument isNull() and parses (from JSON) and returns the user-passed argument, or the default value derived from the RPCArg documentation.
The instantiation of this helper for type R must match the corresponding RPCArg::Type.
The value of the RPC argument (or the default value) cast to type R.
| Name | Description |
|---|---|
| key | The name of the argument to fetch. |
MaybeArg for handling optional arguments without default values.