flawless-http
HTTP client for https://flawless.dev.
This library takes a lot of inspiration from
ureq
. I'm very grateful for all the work thatalgesten
,jsha
and other contributors have done onureq
. ❤️
Quick start
A simple GET request would look like this.
use workflow;
use get;
Body
A request can contain a body, but depending on the body type, additional request headers might be set. If headers are already manually set by the user, they are not overwritten.
Text arguments
In case a String
or &str
type is given to body
, the "Content-Length"
header is
going to be set to the byte length of the string.
use post;
let response = post
.body
.send;
assert!;
Form arguments
In case a slice of tuples of strings is passed in (&[(&str, &str)]
), body
will assume
a for is being submitted and URL encode it. It will set the header "Content-Type"
to
"application/x-www-form-urlencoded"
, and "Content-Length"
to the size of the encoded
content.
use post;
let response = post
.body
.send;
assert!;
JSON arguments
In case of a [serde_json::Value
] type, body
will assume that the content is of type
JSON and set the header "Content-Type"
to "application/json"
. It will also set
"Content-Length"
to the size of the serialized JSON.
use post;
use json;
let response = post
.body
.send;
assert!;