expression
Request builder: method, target and body
Build a typed request before choosing a transport. The generic body type is application data; constructing the request does not connect to a server. External crate example; constructs data in memory, does not send requests. Expected stdout (not executed): POST /notes draft Common mistake: Assuming Request::builder sends a request.
Formal Syntax & Structure
rust syntaxrust
http::Request::builder().method(...).uri(...).body(value)Working Example
Example Snippetrust
fn main() { use http::{Method, Request}; let req = Request::builder().method(Method::POST).uri("/notes").body("draft").unwrap(); println!("{} {} {}", req.method(), req.uri(), req.body());}