Macro anterofit::body[][src]

macro_rules! body {
    ($body:expr) => { ... };
    (EAGER: $body:expr) => { ... };
}

Serialize the given value as the request body.

Serialization will be performed on the adapter's executor, using the adapter's serializer, when the request is submitted.

If the value is intended to be read directly as the request body, wrap it with RawBody.

By default, serialization will be done on the adapter's executor, so the body type must be Send + 'static.

If you want to serialize borrowed values or other types which cannot be sent to other threads, use the EAGER: contextual keyword, which will cause the body to be immediately serialized on the current thread.

Overwrites Body

Setting a new body will overwrite any previous body on the request.

Disallowed verbs: GET, DELETE

GET and DELETE requests are generally not expected to have bodies. As an anti-footgun, Anterofit does not allow bodies on these requests by default.

Wrap this invocation in force_body!() if you want to set a body anyways.

See net::method::TakesBody for more details.