pub enum CsrfError {
TokenMissing,
TokenInvalid,
OriginRejected,
MultipartNotEnabled,
BodyTooLarge,
BodyRead,
Internal,
}Expand description
Reason a request was rejected by CsrfMiddleware.
Implements ResponseError, so by default it
renders as {"error":"<code>"} (see code) with
the status in status_code, Content-Type: application/json. A copy is stored in the response
extensions, so an app’s ErrorHandlers can recover it
with res.response().extensions().get::<CsrfError>()
and re-render in its own shape.
Variants§
TokenMissing
No token in the configured header or body
field on a mutating request. 400.
TokenInvalid
Token present but failed verification. 400.
OriginRejected
Origin/Referer rejected by strict
enforcement. 403.
MultipartNotEnabled
multipart/form-data request while
with_multipart is disabled. 400.
BodyTooLarge
Body exceeded max_body_bytes before the
token could be read. 413.
BodyRead
Request body could not be read. 400.
Internal
Middleware fault. 500. The body is generic;
the cause is logged server-side and never sent
to the client.
Implementations§
Trait Implementations§
Source§impl Error for CsrfError
impl Error for CsrfError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl ResponseError for CsrfError
impl ResponseError for CsrfError
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Source§fn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
impl Copy for CsrfError
impl Eq for CsrfError
impl StructuralPartialEq for CsrfError
Auto Trait Implementations§
impl Freeze for CsrfError
impl RefUnwindSafe for CsrfError
impl Send for CsrfError
impl Sync for CsrfError
impl Unpin for CsrfError
impl UnsafeUnpin for CsrfError
impl UnwindSafe for CsrfError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.