mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-19 03:09:44 -07:00
25 lines
534 B
Rust
25 lines
534 B
Rust
use axum::{
|
|
body::Body,
|
|
http::{Response, StatusCode},
|
|
response::IntoResponse,
|
|
};
|
|
|
|
/// Website result type.
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
/// Website error type that maps to HTTP status codes.
|
|
#[derive(Debug)]
|
|
pub struct Error(StatusCode, String);
|
|
|
|
impl Error {
|
|
pub fn not_found(msg: impl Into<String>) -> Self {
|
|
Self(StatusCode::NOT_FOUND, msg.into())
|
|
}
|
|
}
|
|
|
|
impl IntoResponse for Error {
|
|
fn into_response(self) -> Response<Body> {
|
|
(self.0, self.1).into_response()
|
|
}
|
|
}
|