Switch to axum from warp

The warp repo hasn't seen any activity in over a year; project seems
fairly dead.
This commit is contained in:
2025-07-29 04:34:30 -07:00
parent 720ecac8f8
commit 001a0214d8
4 changed files with 225 additions and 315 deletions

View File

@@ -27,11 +27,11 @@ mod gitlab_webhook;
mod mail_archive;
mod matrix;
use std::{env, net::IpAddr, process::exit};
use std::{env, process::exit};
use anyhow::Context;
use futures::future::join_all;
use warp::Filter;
use tokio::net::TcpListener;
async fn run() -> anyhow::Result<()> {
info!("{} v{} starting...", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
@@ -50,18 +50,14 @@ async fn run() -> anyhow::Result<()> {
};
if let Some(gitlab_webhook) = config.gitlab_webhook.take() {
let gitlab = gitlab_webhook::build_route(gitlab_webhook, matrix_client.clone())?;
let routes = gitlab.with(warp::log("bebot"));
let addr = config
.bind_address
.as_ref()
.cloned()
.unwrap_or_else(|| "127.0.0.1".to_string())
.parse::<IpAddr>()
.context("Failed to parse bind_address")?;
let port = config.bind_port.unwrap_or(3000);
warp::serve(routes).run((addr, port)).await;
let gitlab = gitlab_webhook::build_route(gitlab_webhook, matrix_client.clone());
let bind_addr = format!(
"{}:{}",
config.bind_address.as_deref().unwrap_or("127.0.0.1"),
config.bind_port.unwrap_or(3000)
);
let listener = TcpListener::bind(bind_addr).await?;
axum::serve(listener, gitlab).await?;
}
join_all(handles).await;