add gitea sig header check, add Json errors, begin AppState

This commit is contained in:
2026-05-31 20:32:49 +00:00
parent c119bed142
commit aa746f357d
10 changed files with 288 additions and 37 deletions
+40
View File
@@ -0,0 +1,40 @@
use axum::response::IntoResponse;
use reqwest::StatusCode;
#[derive(thiserror::Error, Debug)]
pub enum AppError {
#[error("Malformed Json")]
MalformedJsonErr,
#[error("Json not contains mandatory fields")]
BadJsonStructErr,
#[error("WebHook sig header not found")]
WebHookSigHeaderNotFoundErr,
#[error("WebHook sig header is invalid")]
WebHookSigHeaderInvalidErr,
#[error(transparent)]
Other(#[from] anyhow::Error),
}
impl IntoResponse for AppError {
fn into_response(self) -> axum::response::Response {
match self {
AppError::MalformedJsonErr => (StatusCode::BAD_REQUEST, "Malformed Json"),
AppError::BadJsonStructErr => (
StatusCode::BAD_REQUEST,
"Json not contains mandatory fields",
),
AppError::WebHookSigHeaderNotFoundErr => {
(StatusCode::BAD_REQUEST, "WebHook sig header not found")
}
AppError::WebHookSigHeaderInvalidErr => {
(StatusCode::BAD_REQUEST, "WebHook sig header is invalid")
}
AppError::Other(_) => (StatusCode::INTERNAL_SERVER_ERROR, "Internal server error"),
}
.into_response()
}
}