Support optional URL prefix for hook URL
This commit is contained in:
16
src/main.rs
16
src/main.rs
@ -161,8 +161,20 @@ async fn run() -> anyhow::Result<()> {
|
||||
|
||||
let matrix_client = matrix_connect(&config).await.context("Failed to connect to Matrix")?;
|
||||
|
||||
let gitlab = warp::path!("hooks" / "gitlab")
|
||||
.and(warp::path::end())
|
||||
let gitlab_root_path = if let Some(url_prefix) = config.url_prefix.as_ref() {
|
||||
url_prefix.split('/').fold(warp::any().boxed(), |last, segment| {
|
||||
if segment.is_empty() {
|
||||
last
|
||||
} else {
|
||||
last.and(warp::path(segment.to_string())).boxed()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
warp::any().boxed()
|
||||
};
|
||||
|
||||
let gitlab = gitlab_root_path
|
||||
.and(warp::path!("hooks" / "gitlab"))
|
||||
.and(warp::post())
|
||||
.and(warp::header::<String>("x-gitlab-token"))
|
||||
.and(warp::body::json())
|
||||
|
Reference in New Issue
Block a user