Skip to main content

Request

Struct Request 

Source
pub struct Request {
    pub method: String,
    pub target: String,
    pub headers: Headers,
    pub body: Vec<u8>,
    pub peer: Option<SocketAddr>,
    pub client_id: Option<String>,
}
Expand description

a request as the server sees it (and as the client sends it)

Fields§

§method: String§target: String

path and query, as sent (“/api/jobs?limit=5”)

§headers: Headers§body: Vec<u8>§peer: Option<SocketAddr>

the remote address (server side)

§client_id: Option<String>

the identity the transport proved (TLS client certificate), if any

Implementations§

Source§

impl Request

Source

pub fn new(method: &str, target: &str) -> Request

Source

pub fn path(&self) -> &str

the path without the query

Source

pub fn query(&self, key: &str) -> Option<String>

a query parameter, decoded

Source

pub fn header(&self, name: &str) -> Option<&str>

Source

pub fn json(&self, limits: Limits) -> Option<Value>

the body as JSON (None: not JSON or over the limits)

Source

pub fn bearer(&self) -> Option<&str>

the bearer token of the Authorization header

Trait Implementations§

Source§

impl Debug for Request

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Request

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Request

§

impl Freeze for Request

§

impl Move for Request

§

impl RefUnwindSafe for Request

§

impl Send for Request
where RawVecInner: Send,

§

impl Sync for Request
where RawVecInner: Sync,

§

impl Unpin for Request
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Request

§

impl UnwindSafe for Request
where RawVecInner: UnwindSafe,

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.