|
@@ -2,12 +2,14 @@ use actix_web::{HttpServer, App, middleware, web, rt};
|
|
|
use awc::ws::Message;
|
|
use awc::ws::Message;
|
|
|
use tokio::sync::mpsc;
|
|
use tokio::sync::mpsc;
|
|
|
use std::sync::Mutex;
|
|
use std::sync::Mutex;
|
|
|
|
|
+use crate::environment::Environment;
|
|
|
|
|
|
|
|
mod routes;
|
|
mod routes;
|
|
|
mod controllers;
|
|
mod controllers;
|
|
|
mod websocket;
|
|
mod websocket;
|
|
|
mod users;
|
|
mod users;
|
|
|
mod logic;
|
|
mod logic;
|
|
|
|
|
+mod environment;
|
|
|
|
|
|
|
|
#[actix_web::main]
|
|
#[actix_web::main]
|
|
|
async fn main() -> Result<(), std::io::Error> {
|
|
async fn main() -> Result<(), std::io::Error> {
|
|
@@ -16,6 +18,7 @@ async fn main() -> Result<(), std::io::Error> {
|
|
|
let port: u16 = env_var("PORT");
|
|
let port: u16 = env_var("PORT");
|
|
|
let ha_ip: String = env_var("HA_IP");
|
|
let ha_ip: String = env_var("HA_IP");
|
|
|
let ha_token: String = env_var("HA_TOKEN");
|
|
let ha_token: String = env_var("HA_TOKEN");
|
|
|
|
|
+ let app_env: Environment = env_var("APP_ENV");
|
|
|
|
|
|
|
|
//Read User Data
|
|
//Read User Data
|
|
|
let users = Mutex::new(users::User::read());
|
|
let users = Mutex::new(users::User::read());
|
|
@@ -31,6 +34,7 @@ async fn main() -> Result<(), std::io::Error> {
|
|
|
App::new()
|
|
App::new()
|
|
|
.app_data(users_data.clone())
|
|
.app_data(users_data.clone())
|
|
|
.app_data(ha_sender.clone())
|
|
.app_data(ha_sender.clone())
|
|
|
|
|
+ .app_data(app_env.clone())
|
|
|
.wrap(middleware::Compress::default())
|
|
.wrap(middleware::Compress::default())
|
|
|
.configure(routes::config)
|
|
.configure(routes::config)
|
|
|
})
|
|
})
|