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:
24
src/main.rs
24
src/main.rs
@@ -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;
|
||||
|
Reference in New Issue
Block a user