pub struct EndpointResponse { /* private fields */ }Expand description
A returned value or intentional API error, available to completed endpoint hooks.
Implementations§
Source§impl EndpointResponse
impl EndpointResponse
pub fn value(value: JsValue) -> Self
Sourcepub fn json(value: &impl Serialize) -> AuthResult<Self>
pub fn json(value: &impl Serialize) -> AuthResult<Self>
§Errors
Returns an error if the endpoint value cannot be serialized.
Sourcepub fn from_http_response(response: AuthResponse) -> Self
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.
pub const fn http_response(&self) -> Option<&AuthResponse>
pub fn http_response_mut(&mut self) -> Option<&mut AuthResponse>
Sourcepub fn to_response(&self) -> AuthResult<AuthResponse>
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.
pub fn error(error: AuthError) -> Self
Sourcepub fn redirect(location: impl Into<String>) -> Self
pub fn redirect(location: impl Into<String>) -> Self
Preserve an intentional redirect error, including its absent body and Location.
Sourcepub fn without_error_body(self) -> Self
pub fn without_error_body(self) -> Self
Retain the distinction between an absent error body and an explicit JSON null.
pub const fn error_body_is_absent(&self) -> bool
pub fn with_error_body(self, body: JsValue) -> Self
pub const fn error_body(&self) -> Option<&JsValue>
pub const fn result(&self) -> &Result<JsValue, AuthError>
pub const fn headers(&self) -> &Headers
pub const fn status(&self) -> Option<u16>
pub fn set_status(&mut self, status: Option<u16>)
pub fn with_status(self, status: u16) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
pub fn merge_headers(&mut self, headers: Headers)
Sourcepub fn replace(&mut self, value: JsValue)
pub fn replace(&mut self, value: JsValue)
Replace a returned value while retaining the actual handler status and headers.
pub fn replace_error(&mut self, error: AuthError)
pub fn into_output<T>(self) -> Result<EndpointOutput<T>, EndpointError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EndpointResponse
impl !UnwindSafe for EndpointResponse
impl Freeze for EndpointResponse
impl Send for EndpointResponse
impl Sync for EndpointResponse
impl Unpin for EndpointResponse
impl UnsafeUnpin for EndpointResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more