Type Definition gotham_restful::AuthResult
source · [−]pub type AuthResult<T, E> = Result<T, AuthErrorOrOther<E>>;
Expand description
This return type can be used to wrap any type implementing IntoResponse that can only be returned if the client is authenticated. Otherwise, an empty 403 Forbidden response will be issued.
Use can look something like this (assuming the auth
feature is enabled):
#[read_all]
fn read_all(auth : AuthStatus<MyAuthData>) -> AuthResult<NoContent, io::Error> {
let auth_data = match auth {
AuthStatus::Authenticated(data) => data,
_ => Err(Forbidden)?
};
// do something
Ok(NoContent::default().into())
}