use axum::http::StatusCode; use axum::routing::get; use axum::routing::post; use axum::Json; use axum::Router; use serde::Serialize; use tower_http::trace::TraceLayer; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; use self::webhook::hook; mod webhook; #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::registry() .with( tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| { "webhook_bridge=info,tower_http=debug,axum::rejection=trace".into() }), ) .with(tracing_subscriber::fmt::layer()) .init(); let app = Router::new() .route("/health", get(health)) .route("/hook", post(hook)) .layer(TraceLayer::new_for_http()); let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?; tracing::info!("listening on {}", listener.local_addr().unwrap()); axum::serve(listener, app).await?; Ok(()) } async fn health() -> (StatusCode, Json) { (StatusCode::OK, Json(HealthResponse { ok: true })) } #[derive(Serialize)] struct HealthResponse { ok: bool, }