diff --git a/src/state.rs b/src/state.rs index 1c00923..dd74d17 100644 --- a/src/state.rs +++ b/src/state.rs @@ -14,6 +14,7 @@ pub struct State { #[derive(Clone, Deserialize)] pub struct Config { + pub bind_address: String, pub matrix_id: String, pub matrix_room: String, pub matrix_store: PathBuf, diff --git a/src/web.rs b/src/web.rs index d7a5990..02d16d2 100644 --- a/src/web.rs +++ b/src/web.rs @@ -8,6 +8,7 @@ use matrix_sdk::ruma::RoomId; use monzo::accounts::Type; use serde::Deserialize; use std::collections::HashMap; +use std::net::SocketAddr; use std::str::FromStr; use url::Url; use warp::http::{Response, StatusCode}; @@ -207,7 +208,10 @@ async fn monzo_hook_wrapped( /// - setting up Monzo access tokens /// - receiving Monzo webhooks pub async fn warp_main(state: State) { - let with_state = warp::any().map(move || state.clone()); + let with_state = { + let state = state.clone(); + warp::any().map(move || state.clone()) + }; let auth_setup_route = warp::get() .and(warp::path("auth_setup")) // .and(warp::header("Host")) @@ -237,5 +241,7 @@ pub async fn warp_main(state: State) { .or(auth_confirmed_route) .or(hook_route); - warp::serve(routes).run(([127, 0, 0, 1], 3030)).await; + let address: SocketAddr = + SocketAddr::from_str(&state.config.bind_address).expect("Failed to parse bind address"); + warp::serve(routes).run(address).await; }