Struct dyer::component::request::RequestBuilder[][src]

pub struct RequestBuilder { /* fields omitted */ }
Expand description

An Wrapper of http::request::Builder

An HTTP request builder

This type can be used to construct an instance or Request through a builder-like pattern.

Implementations

Create an instance of RequestBuilder that used to build a Request
Same as Request::builder()

Examples
let request = RequestBuilder::new()
    .body(());

set the uri of Task, if not called, the default value is “/”

Examples
let task = TaskBuilder::new()
    .uri("https://example.com")
    .parser(parser_fn)
    .body(());

get shared reference to uri of TaskBuilder Same as Task::uri(...)

Examples
let uri = "https://example.com";
let task = TaskBuilder::new()
    .uri(uri)
    .parser(parser_fn)
    .body(());
assert_eq!(task.uri_ref(), uri);

set the method of Task

Examples
let method = Method::POST;
let task = TaskBuilder::new()
    .method(method)
    .parser(parser_fn)
    .body(());
assert_eq!(task.method_ref(), method);

get shared reference to method of TaskBuilder Same as Task::method(...)

Examples
let method = Method::POST;
let task = TaskBuilder::new()
    .method(method)
    .parser(parser_fn)
    .body(());
assert_eq!(task.method_ref(), method);

get shared reference to header of TaskBuilder Same as Task::headers(...)

Examples
let task = TaskBuilder::new()
    .header("accept", "*/*")
    .parser(parser_fn)
    .body(());
assert_eq!(task.header_ref()["accept"], "*/*");

get mutable reference to header of TaskBuilder

Examples
let task = TaskBuilder::new()
    .header("accept", "*/*")
    .parser(parser_fn)
    .body(());
task.header_mut().insert("accept", "text/html");
assert_eq!(task.header_ref()["accept"], "text/html");

set the headers of Task

Examples
let task = TaskBuilder::new()
    .header("accept", "*/*")
    .parser(parser_fn)
    .body(());
assert_eq!(task.header_ref()["accept"], "*/*");

set the version of Task

Examples
let task = TaskBuilder::new()
    .version(Version::HTTP_10)
    .parser(parser_fn)
    .body(());
assert_eq!(task.version_ref(), Version::HTTP_10);

get shared reference to version of TaskBuilder Same as Task::version(...)

Examples
let version = Version::HTTP_10;
let task = TaskBuilder::new()
    .version(version)
    .parser(parser_fn)
    .body(());
assert_eq!(task.version_ref(), version);

Take this RequestBuilder and combine the body to create a Request

Examples
let _ = RequestBuilder::new()
    .body(());

get shared reference to extensions of RequestBuilder Same as Request::extensions(...)

Examples
struct S {}
let request = RequestBuilder::new()
    .body(());
let s = S {};
request.extensions_mut.insert(s);
assert_eq!(request.extensions_ref().get::<S>(), &s);

get mutable reference to extensions of RequestBuilder

Examples
let request = RequestBuilder::new()
    .body(());
request.extensions_mut().insert(vec![1,2,3]);
assert_eq!(request.extensions_ref().get::<Vec<_>>(), &vec![1,2,3]);

set the exts of Request

Examples
let Request = RequestBuilder::new()
    .extensions(vec![1,2,3])
    .body(());
assert_eq!(Request.extensions_ref(), &vec![1,2,3]);

get shared reference to exts of RequestBuilder Same as Request::exts(...)

Examples
struct S {}
let request = RequestBuilder::new()
    .body(());
let s = S {};
request.exts_mut.insert(s);
assert_eq!(request.exts_ref().get::<S>(), &s);

get mutable reference to exts of RequestBuilder

Examples
let request = RequestBuilder::new()
    .body(());
request.exts_mut().insert(vec![1,2,3]);
assert_eq!(request.exts_ref().get::<Vec<_>>(), &vec![1,2,3]);

set the exts of Request

Examples
let Request = RequestBuilder::new()
    .exts(vec![1,2,3])
    .body(());
assert_eq!(Request.exts_ref(), &vec![1,2,3]);

set the body_fn of Request,

Examples
let task = RequestBuilder::new()
    .body_fn(body_fn)
    .body(());
assert_eq!(*Request.body_fn_ref(), body_fn);

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more