Struct HeaderBuilder

Source
pub struct HeaderBuilder { /* private fields */ }

Implementations§

Source§

impl HeaderBuilder

Source

pub fn new() -> Self

Source

pub fn with_capacity(capacity: usize) -> Self

Source

pub fn header(&mut self, key: HeaderName, value: HeaderValue) -> &mut Self

Source

pub fn header_static( &mut self, key: HeaderName, value: &'static str, ) -> &mut Self

Source

pub fn header_str( &mut self, key: HeaderName, value: &str, ) -> Result<&mut Self, HeaderError>

Source

pub fn append( &mut self, key: HeaderName, value: HeaderValue, ) -> Result<&mut Self, Error>

Source

pub fn client_id(&mut self, id: &str) -> Result<&mut Self, HeaderError>

Client-Id:

Source

pub fn user_agent(&mut self, agent: &str) -> Result<&mut Self, HeaderError>

User-Agent:

Source

pub fn cache_control_no_cache(&mut self) -> &mut Self

Cache-Control: no-cache

Source

pub fn cache_control(&mut self, value: &str) -> Result<&mut Self, HeaderError>

Cache-Control:

Source

pub fn api_key(&mut self, key: &str) -> Result<&mut Self, HeaderError>

X-API-Key:

Source

pub fn request_id(&mut self, id: &str) -> Result<&mut Self, HeaderError>

X-Request-ID:

Source

pub fn origin(&mut self, origin: &str) -> Result<&mut Self, HeaderError>

Origin:

Source

pub fn referer(&mut self, referer: &str) -> Result<&mut Self, HeaderError>

Referer:

Source

pub fn cors_allow_all(&mut self) -> &mut Self

Access-Control-Allow-Origin: *

Source

pub fn cors_allow_origin( &mut self, origin: &str, ) -> Result<&mut Self, HeaderError>

Access-Control-Allow-Origin:

Source

pub fn cors_allow_methods_standard(&mut self) -> &mut Self

Access-Control-Allow-Methods: GET, POST, PUT, DELETE

Source

pub fn cors_allow_headers_standard(&mut self) -> &mut Self

Access-Control-Allow-Headers: Content-Type, Authorization

Source

pub fn connection_keep_alive(&mut self) -> &mut Self

Connection: keep-alive

Source

pub fn connection_close(&mut self) -> &mut Self

Connection: close

Source

pub fn content_length(&mut self, length: u64) -> &mut Self

Content-Length:

Source

pub fn json_api(&mut self) -> &mut Self

Accept: application/json, Content-Type: application/json

Source

pub fn build(self) -> HeaderMap

Source§

impl HeaderBuilder

Source

pub fn accept_json(&mut self) -> &mut Self

ACCEPT: application/json

Source

pub fn accept_html(&mut self) -> &mut Self

ACCEPT: text/html

Source

pub fn accept_text(&mut self) -> &mut Self

ACCEPT: text/plain

Source

pub fn accept_any(&mut self) -> &mut Self

ACCEPT: /

Source

pub fn accept_mulity( &mut self, items: &[&str], ) -> Result<&mut Self, HeaderError>

ACCEPT: multi items

Source

pub fn accept_encoding_standard(&mut self) -> &mut Self

Accept-Encoding: gzip, deflate, br

Source

pub fn accept_language_en(&mut self) -> &mut Self

Accept-Language: en-US, en;q=0.9

Source

pub fn accept_language(&mut self, lang: &str) -> Result<&mut Self, HeaderError>

Accept-Language:

Source§

impl HeaderBuilder

Source

pub fn content_type_formencoded(&mut self) -> &mut Self

CONTENT-TYPE: application/x-www-form-urlencoded

Source

pub fn content_type_json(&mut self) -> &mut Self

CONTENT-TYPE: application/json

Source

pub fn content_type_text(&mut self) -> &mut Self

CONTENT-TYPE: text/plain

Source

pub fn content_type_html(&mut self) -> &mut Self

CONTENT-TYPE: text/html

Source

pub fn content_type_multipart(&mut self) -> &mut Self

CONTENT-TYPE: multipart/form-data

Source§

impl HeaderBuilder

Source

pub fn authorization(&mut self, auth: AuthScheme<'_>) -> &mut Self

Authorization:

Source

pub fn basic_auth(&mut self, username: &str, password: &str) -> &mut Self

Source

pub fn bearer_token(&mut self, token: &str) -> &mut Self

Trait Implementations§

Source§

impl Debug for HeaderBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,