make backend more configuratble
This commit is contained in:
parent
c3bc32bb2b
commit
e303b5ed45
|
@ -424,7 +424,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cryptgeon"
|
||||
version = "2.0.1"
|
||||
version = "2.0.2"
|
||||
dependencies = [
|
||||
"actix-files",
|
||||
"actix-web",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "cryptgeon"
|
||||
version = "2.0.1"
|
||||
version = "2.0.2"
|
||||
authors = ["cupcakearmy <hi@nicco.io>"]
|
||||
edition = "2021"
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
use actix_files::{Files, NamedFile};
|
||||
use actix_web::{web, Result};
|
||||
|
||||
use crate::config;
|
||||
|
||||
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
Files::new("/", "./frontend/build")
|
||||
Files::new("/", config::FRONTEND_PATH.to_string())
|
||||
.index_file("index.html")
|
||||
.use_etag(true),
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn index() -> Result<NamedFile> {
|
||||
Ok(NamedFile::open("./frontend/build/index.html")?)
|
||||
let index = format!("{}{}", config::FRONTEND_PATH.to_string(), "/index.html");
|
||||
Ok(NamedFile::open(index)?)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
use byte_unit::Byte;
|
||||
|
||||
// General
|
||||
// Internal
|
||||
lazy_static! {
|
||||
pub static ref VERSION: String = option_env!("CARGO_PKG_VERSION")
|
||||
.unwrap_or("Unknown")
|
||||
.to_string();
|
||||
pub static ref FRONTEND_PATH: String = option_env!("FRONTEND_PATH")
|
||||
.unwrap_or("../frontend/build")
|
||||
.to_string();
|
||||
pub static ref LISTEN_ADDR: String = option_env!("LISTEN_ADDR")
|
||||
.unwrap_or("0.0.0.0:5000")
|
||||
.to_string();
|
||||
}
|
||||
|
||||
// CONFIG
|
||||
|
|
|
@ -29,7 +29,7 @@ async fn main() -> std::io::Result<()> {
|
|||
.configure(client::init)
|
||||
.default_service(web::to(client::index))
|
||||
})
|
||||
.bind("0.0.0.0:5000")?
|
||||
.bind(config::LISTEN_ADDR.to_string())?
|
||||
.run()
|
||||
.await;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue