Trait WebResponse

Source
pub trait WebResponse {
    type Error;

    // Required methods
    fn ok(&mut self) -> Result<(), Self::Error>;
    fn redirect(&mut self, url: Url) -> Result<(), Self::Error>;
    fn client_error(&mut self) -> Result<(), Self::Error>;
    fn unauthorized(&mut self, header_value: &str) -> Result<(), Self::Error>;
    fn body_text(&mut self, text: &str) -> Result<(), Self::Error>;
    fn body_json(&mut self, data: &str) -> Result<(), Self::Error>;
}
Expand description

Response representation into which the Request is transformed by the code_grant types.

At most one of the methods body_text, body_json will be called. Some flows will however not call any of those methods.

Required Associated Types§

Source

type Error

The error generated when trying to construct an unhandled or invalid response.

Required Methods§

Source

fn ok(&mut self) -> Result<(), Self::Error>

Set the response status to 200.

Source

fn redirect(&mut self, url: Url) -> Result<(), Self::Error>

A response which will redirect the user-agent to which the response is issued.

Source

fn client_error(&mut self) -> Result<(), Self::Error>

Set the response status to 400.

Source

fn unauthorized(&mut self, header_value: &str) -> Result<(), Self::Error>

Set the response status to 401 and add a WWW-Authenticate header.

Source

fn body_text(&mut self, text: &str) -> Result<(), Self::Error>

A pure text response with no special media type set.

Source

fn body_json(&mut self, data: &str) -> Result<(), Self::Error>

Json repsonse data, with media type `aplication/json.

Implementors§

Source§

impl WebResponse for Response

Source§

impl<W: WebResponse, F, T> WebResponse for MapErr<W, F, T>
where F: FnMut(W::Error) -> T,

Source§

type Error = T