mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-09-27 13:50:03 +00:00
25 lines
731 B
Rust
25 lines
731 B
Rust
use actix_web::http::header::LOCATION;
|
|
use actix_web::HttpResponse;
|
|
|
|
// Return an opaque 500 while preserving the error root's cause for logging.
|
|
pub fn e500<T>(e: T) -> actix_web::Error
|
|
where
|
|
T: std::fmt::Debug + std::fmt::Display + 'static,
|
|
{
|
|
actix_web::error::ErrorInternalServerError(e)
|
|
}
|
|
|
|
// Return a 400 with the user-representation of the validation error as body.
|
|
// The error root cause is preserved for logging purposes.
|
|
pub fn e400<T>(e: T) -> actix_web::Error
|
|
where
|
|
T: std::fmt::Debug + std::fmt::Display + 'static,
|
|
{
|
|
actix_web::error::ErrorBadRequest(e)
|
|
}
|
|
|
|
pub fn see_other(location: &str) -> HttpResponse {
|
|
HttpResponse::SeeOther()
|
|
.insert_header((LOCATION, location))
|
|
.finish()
|
|
}
|