submit

Macro submit 

Source
macro_rules! submit {
    ($method:expr, $input:expr, $url:expr, &mut $client:ident) => { ... };
}
Expand description

Submit a request to the specified URL.

The submit! macro is a more generic version of the get! macro. Its first argument is a string literal or a variable. Arrows are used to specify the body serialization type and the output type.

You can use the JsonBody, XmlBody, MsgPack type for JSON, XML and MessagePack serialization.

To help understand the macro arguments, here is an example:

fetch!(url, &mut client, body, ty)

§Arguments

  • method - The HTTP method to use.
  • input - The input to send with the request.
  • url - The URL to make the GET request to.
  • client - The client variable to use for the request.
  • res_body_ty - The body type of the response.
  • res_ty - The type of the response.

Please note url can be a string literal or a variable.

§Example

let mut client = Deboa::new();
let response = submit!("POST", "user=deboa", "https://jsonplaceholder.typicode.com/posts", &mut client);
assert_eq!(response.id, 1);