ticker-serve/index: make http_bind configurable

This commit is contained in:
Astro 2023-03-17 23:21:48 +01:00
parent c2d8306861
commit 1a55ead24d
3 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,7 @@ pub struct CalendarOptions {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Config {
pub db_url: String,
pub http_bind: String,
pub calendars: BTreeMap<String, CalendarOptions>,
pub weekdays: Vec<String>,
pub months: Vec<String>,

View File

@ -19,6 +19,7 @@ let
];
upcoming_days = 28;
passed_days = 7;
http_bind = "0.0.0.0:8400";
};
tickerConfig = defaultTickerConfig // cfg.config;
configFile = pkgs.writeText "config.yaml" (lib.generators.toYAML {} tickerConfig);

View File

@ -24,6 +24,7 @@ pub struct AppState {
fn main() {
let config = Config::read_yaml_file("config.yaml");
let http_bind = config.http_bind.clone();
let db = PgConnection::establish(&config.db_url)
.expect("DB");
@ -46,6 +47,6 @@ fn main() {
.build()
);
});
gotham::start("0.0.0.0:8400", router)
gotham::start(http_bind, router)
.unwrap()
}