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