fn construct_request<I, K, V>(
    url: &url::Url,
    params: I,
    headers: http::HeaderMap,
    method: http::Method,
    body: Vec<u8>,
) -> HttpRequest
where
    I: std::iter::IntoIterator,
    I::Item: std::borrow::Borrow<(K, V)>,
    K: AsRef<str>,
    V: AsRef<str>,
{
    let mut url = url.clone();
    url.query_pairs_mut().extend_pairs(params);
    let url: String = url.into();
    let mut req = http::Request::builder().method(method).uri(url);
    req.headers_mut()
        .map(|h| h.extend(headers.into_iter()))
        .unwrap();
    req.headers_mut()
        .map(|h| {
            if !h.contains_key(http::header::ACCEPT) {
                h.append(http::header::ACCEPT, "application/json".parse().unwrap());
            }
        })
        .unwrap();
    req.body(body).unwrap()
}
/// Construct a request that accepts `application/json` on default
Construct a request that accepts `application/json` on default
Construct a request that accepts ` application / json ` on default
fn construct_request<I, K, V>(
    url: &url::Url,
    params: I,
    headers: http::HeaderMap,
    method: http::Method,
    body: Vec<u8>,
) -> HttpRequest
where
    I: std::iter::IntoIterator,
    I::Item: std::borrow::Borrow<(K, V)>,
    K: AsRef<str>,
    V: AsRef<str>,
{
    let mut url = url.clone();
    url.query_pairs_mut().extend_pairs(params);
    let url: String = url.into();
    let mut req = http::Request::builder().method(method).uri(url);
    req.headers_mut()
        .map(|h| h.extend(headers.into_iter()))
        .unwrap();
    req.headers_mut()
        .map(|h| {
            if !h.contains_key(http::header::ACCEPT) {
                h.append(http::header::ACCEPT, "application/json".parse().unwrap());
            }
        })
        .unwrap();
    req.body(body).unwrap()
}
fn construct_request < I , K , V > ( url : & url :: Url , params : I , headers : http :: HeaderMap , method : http :: Method , body : Vec < u8 > , ) -> HttpRequest where I : std :: iter :: IntoIterator , I :: Item : std :: borrow :: Borrow < ( K , V ) > , K : AsRef < str > , V : AsRef < str > , { let mut url = url . clone ( ) ; url . query_pairs_mut ( ) . extend_pairs ( params ) ; let url : String = url . into ( ) ; let mut req = http :: Request :: builder ( ) . method ( method ) . uri ( url ) ; req . headers_mut ( ) . map ( | h | h . extend ( headers . into_iter ( ) ) ) . unwrap ( ) ; req . headers_mut ( ) . map ( | h | { if ! h . contains_key ( http :: header :: ACCEPT ) { h . append ( http :: header :: ACCEPT , " " . parse ( ) . unwrap ( ) ) ; } } ) . unwrap ( ) ; req . body ( body ) . unwrap ( ) }
Construct a request that accepts `application/json` on default
Construct a request that accepts ` application / json ` on default
url
&url::Url
params
I
headers
http::HeaderMap
method
http::Method
body
Vec<u8>