Allow configuring the bind address
This commit is contained in:
parent
1095ef0aa6
commit
c10eeafed1
|
@ -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,
|
||||
|
|
10
src/web.rs
10
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue