Starting impl Sentry and tracing

This commit is contained in:
2026-06-09 20:58:38 +00:00
parent 3984a7d3ba
commit 39c2afa0a7
10 changed files with 1456 additions and 84 deletions
+9 -1
View File
@@ -1,13 +1,17 @@
use axum::body::{Bytes, to_bytes};
use axum::body::{Body, Bytes, to_bytes};
use axum::extract::{FromRef, FromRequest, State};
use axum::http::Request;
use axum::response::IntoResponse;
use axum::routing::{get, post};
use axum::{Json, Router};
use hmac::{Hmac, KeyInit, Mac};
use reqwest::StatusCode;
use sentry::integrations::tower::NewSentryLayer;
use serde_json::Value;
use sha2::Sha256;
use subtle::ConstantTimeEq;
use tower_http::trace::TraceLayer;
use tracing::info;
use crate::consts::{GITEA_EVENT_TYPE_HEADER_NAME, GITEA_SIG_HEADER_NAME, MAX_WEBHOOK_BODY_SIZE};
use crate::errors::AppError;
@@ -18,11 +22,15 @@ pub async fn start(app_state: AppState) -> anyhow::Result<()> {
let http_port = app_state.config.http_port;
let app = Router::new()
.layer(NewSentryLayer::<Request<Body>>::new_from_top())
.layer(TraceLayer::new_for_http())
.route("/", get(root))
.route("/webhook", post(webhook))
.with_state(app_state);
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", http_port)).await?;
info!("Listening API on port {}", http_port);
axum::serve(listener, app)
.await
.map_err(anyhow::Error::from)