Crate http_request_derive

Source
Expand description

Attention: this crate is still under development.

You can derive HttpRequest on a struct and annotate it with some attributes, so that it can be used to build a http::Request which can then be sent to a server. In addition, a response type can be read from the received http::Response.

use http_request_derive::HttpRequest;
use serde::Deserialize;

#[derive(HttpRequest)]
#[http_request(method = "GET", response = MyResponse, path = "/books/{id}/abstract")]
struct MyRequest {
    #[http_request(query)]
    query: String,

    id: usize,
}

#[derive(Deserialize)]
struct MyResponse {}

Enums§

Error
Errors that originate from this crate

Traits§

FromHttpResponse
Trait for types that can be converted from http::Response
HttpRequest
A trait implemented for types that are sent to the API as parameters
HttpRequestBody
Trait defined on every body type that can be used with crate::HttpRequest.
HttpRequestQueryParams
A trait implemented by entities tha can build a HTTP request query string

Derive Macros§

HttpRequest
HttpRequest can be derived by structs that needs to implement the HttpRequest trait.