Trait WebRequest

Source
pub trait WebRequest {
    type Error;
    type Response: WebResponse<Error = Self::Error>;

    // Required methods
    fn query(
        &mut self,
    ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>;
    fn urlbody(
        &mut self,
    ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>;
    fn authheader(&mut self) -> Result<Option<Cow<'_, str>>, Self::Error>;
}
Expand description

Abstraction of web requests with several different abstractions and constructors needed by an endpoint. It is assumed to originate from an HTTP request, as defined in the scope of the rfc, but theoretically other requests are possible.

Required Associated Types§

Source

type Error

The error generated from access of malformed or invalid requests.

Source

type Response: WebResponse<Error = Self::Error>

The corresponding type of Responses returned from this module.

Required Methods§

Source

fn query( &mut self, ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>

Retrieve a parsed version of the url query.

An Err return value indicates a malformed query or an otherwise malformed WebRequest. Note that an empty query should result in Ok(HashMap::new()) instead of an Err.

Source

fn urlbody( &mut self, ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>

Retrieve the parsed application/x-form-urlencoded body of the request.

An Err value / indicates a malformed body or a different Content-Type.

Source

fn authheader(&mut self) -> Result<Option<Cow<'_, str>>, Self::Error>

Contents of the authorization header or none if none exists. An Err value indicates a malformed header or request.

Implementations on Foreign Types§

Source§

impl<'a, W: WebRequest> WebRequest for &'a mut W

Source§

type Error = <W as WebRequest>::Error

Source§

type Response = <W as WebRequest>::Response

Source§

fn query( &mut self, ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>

Source§

fn urlbody( &mut self, ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>

Source§

fn authheader(&mut self) -> Result<Option<Cow<'_, str>>, Self::Error>

Implementors§