Skip to main content

EndpointResponse

Struct EndpointResponse 

Source
pub struct EndpointResponse { /* private fields */ }
Expand description

A returned value or intentional API error, available to completed endpoint hooks.

Implementations§

Source§

impl EndpointResponse

Source

pub fn value(value: JsValue) -> Self

Source

pub fn json(value: &impl Serialize) -> AuthResult<Self>

§Errors

Returns an error if the endpoint value cannot be serialized.

Source

pub fn empty() -> Self

Return no logical value and an empty successful HTTP response.

Source

pub fn from_http_response(response: AuthResponse) -> Self

Return an actual HTTP response value, retaining its bytes, status and headers.

Endpoint hooks still run. Accumulated hook headers and status remain separate from this response until it is forwarded to HTTP.

Source

pub const fn http_response(&self) -> Option<&AuthResponse>

Source

pub fn http_response_mut(&mut self) -> Option<&mut AuthResponse>

Source

pub fn to_response(&self) -> AuthResult<AuthResponse>

Forward the returned value as HTTP, preserving a response value’s own status and body.

§Errors

Returns a serialization error for a JSON value or an intentional API error.

Source

pub fn error(error: AuthError) -> Self

Source

pub fn redirect(location: impl Into<String>) -> Self

Preserve an intentional redirect error, including its absent body and Location.

Source

pub fn without_error_body(self) -> Self

Retain the distinction between an absent error body and an explicit JSON null.

Source

pub const fn error_body_is_absent(&self) -> bool

Source

pub fn with_error_body(self, body: JsValue) -> Self

Source

pub const fn error_body(&self) -> Option<&JsValue>

Source

pub const fn result(&self) -> &Result<JsValue, AuthError>

Source

pub const fn headers(&self) -> &Headers

Source

pub const fn status(&self) -> Option<u16>

Source

pub fn set_status(&mut self, status: Option<u16>)

Source

pub fn with_status(self, status: u16) -> Self

Source

pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Source

pub fn merge_headers(&mut self, headers: Headers)

Source

pub fn replace(&mut self, value: JsValue)

Replace a returned value while retaining the actual handler status and headers.

Source

pub fn replace_error(&mut self, error: AuthError)

Source

pub fn into_output<T>(self) -> Result<EndpointOutput<T>, EndpointError>

Trait Implementations§

Source§

impl Debug for EndpointResponse

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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.
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