diff --git a/Cargo.toml b/Cargo.toml index c9a59b2..6fb3bd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +actix-service = "2.0.2" actix-web = "4.4.0" chrono = { version = "0.4.31", features = ["serde"] } dotenvy = "0.15" @@ -20,4 +21,4 @@ tokio = { version = "1", features = ["fs", "rt-multi-thread"] } [lints.clippy] -pedantic = "warn" \ No newline at end of file +pedantic = "warn" diff --git a/README.md b/README.md index da91d81..1c4bba0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # iot-cloud ## TODO -- Testing of values, displayName etc. -- Automated testing? \ No newline at end of file +- Env var for fw dir +- basic auth for uploading \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f8fcde4..7e97e7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,6 +26,7 @@ async fn main() -> std::io::Result<()> { process::exit(1); } }; + let external_url = env::var("URL").unwrap_or("localhost".to_string()); info!("Connecting to Database {}", db_url); let db = Database::init(&db_url).await; @@ -36,7 +37,7 @@ async fn main() -> std::io::Result<()> { .app_data(web::Data::new(AppState { db: db.clone(), firmwares_path: PathBuf::from("./fw"), - hostname: "0.0.0.0:8282".to_string(), + hostname: external_url.clone(), })) .app_data(web::PayloadConfig::new(256 * 1024 * 1024)) //256MB .service(device_telemetry_api::receive_telemetry) @@ -52,3 +53,4 @@ async fn main() -> std::io::Result<()> { .run() .await } +