Initialize API
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
use axum::{Json, response::IntoResponse};
|
||||
use reqwest::StatusCode;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Error {
|
||||
pub status: u16,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
impl IntoResponse for Error {
|
||||
fn into_response(self) -> axum::response::Response {
|
||||
(
|
||||
StatusCode::from_u16(self.status)
|
||||
.expect("The status code provided was not a valid status code"),
|
||||
Json(self),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user