broker: set rocket server port to http_setting

This commit is contained in:
decentclock
2022-09-30 22:11:10 +00:00
parent 38db744463
commit a3ca7dd9e5
3 changed files with 12 additions and 3 deletions

View File

@@ -127,5 +127,5 @@ async fn run_main(parent_fd: i32) -> rocket::Rocket<rocket::Build> {
signer_loop.start(Some(settings)); signer_loop.start(Some(settings));
}); });
routes::launch_rocket(tx, error_tx) routes::launch_rocket(tx, error_tx, settings)
} }

View File

@@ -1,3 +1,4 @@
use crate::util::Settings;
use crate::ChannelRequest; use crate::ChannelRequest;
use rocket::fairing::{Fairing, Info, Kind}; use rocket::fairing::{Fairing, Info, Kind};
use rocket::http::Header; use rocket::http::Header;
@@ -6,6 +7,8 @@ use rocket::response::stream::{EventStream, Event};
use rocket::tokio::select; use rocket::tokio::select;
use rocket::*; use rocket::*;
use sphinx_key_parser::{topics, error::Error as ParserError}; use sphinx_key_parser::{topics, error::Error as ParserError};
use std::net::IpAddr::V4;
use std::net::Ipv4Addr;
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;
@@ -43,8 +46,14 @@ async fn errors(error_tx: &State<broadcast::Sender<Vec<u8>>>, mut end: Shutdown)
} }
} }
pub fn launch_rocket(tx: Sender<ChannelRequest>, error_tx: broadcast::Sender<Vec<u8>>) -> Rocket<Build> { pub fn launch_rocket(tx: Sender<ChannelRequest>, error_tx: broadcast::Sender<Vec<u8>>, settings: Settings) -> Rocket<Build> {
let config = Config {
address: V4(Ipv4Addr::UNSPECIFIED),
port: settings.http_port,
..Config::debug_default()
};
rocket::build() rocket::build()
.configure(config)
.mount("/api/", routes![control, errors]) .mount("/api/", routes![control, errors])
.attach(CORS) .attach(CORS)
.manage(tx) .manage(tx)

View File

@@ -50,7 +50,7 @@ pub async fn run_test() -> rocket::Rocket<rocket::Build> {
}; };
} }
}); });
launch_rocket(tx, error_tx) launch_rocket(tx, error_tx, settings)
} }
#[allow(dead_code)] #[allow(dead_code)]