Server API v1 #1
@ -1,3 +1,6 @@
|
|||||||
|
PORT=
|
||||||
|
BIND_ADDR=
|
||||||
|
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=
|
||||||
DB_USER=
|
DB_USER=
|
||||||
DB_HOST=
|
DB_HOST=
|
7
server/Cargo.lock
generated
7
server/Cargo.lock
generated
@ -415,6 +415,12 @@ dependencies = [
|
|||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dotenvy"
|
||||||
|
version = "0.15.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "encoding_rs"
|
name = "encoding_rs"
|
||||||
version = "0.8.34"
|
version = "0.8.34"
|
||||||
@ -741,6 +747,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"colored",
|
"colored",
|
||||||
|
"dotenvy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -7,3 +7,4 @@ license = "GPL-3.0-only"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.5.1"
|
actix-web = "4.5.1"
|
||||||
colored = "2.1.0"
|
colored = "2.1.0"
|
||||||
|
dotenvy = "0.15.7"
|
||||||
|
@ -5,6 +5,8 @@ use std::env;
|
|||||||
|
|
||||||
use actix_web::{App, get, HttpResponse, HttpServer, Responder};
|
use actix_web::{App, get, HttpResponse, HttpServer, Responder};
|
||||||
|
|
||||||
|
use crate::util::warn_println;
|
||||||
|
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
@ -15,6 +17,11 @@ async fn main() -> std::io::Result<()> {
|
|||||||
let mut port = 8000;
|
let mut port = 8000;
|
||||||
let mut bind_addr = String::from("127.0.0.1");
|
let mut bind_addr = String::from("127.0.0.1");
|
||||||
|
|
||||||
|
// Load .env
|
||||||
|
if let Err(e) = dotenvy::dotenv() {
|
||||||
|
warn_println(format!("Failed to load dotenv: {}", e))
|
||||||
|
};
|
||||||
|
|
||||||
// If env variable for port or bind_addr is present use that instead of default.
|
// If env variable for port or bind_addr is present use that instead of default.
|
||||||
if let Ok(env_port) = env::var("PORT") {
|
if let Ok(env_port) = env::var("PORT") {
|
||||||
if let Ok(env_port) = env_port.parse::<u16>() {
|
if let Ok(env_port) = env_port.parse::<u16>() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user