mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-22 04:19:47 -05:00
feat(config): use an environment variable for config file path
This commit is contained in:
parent
ee760529a3
commit
411f278656
1 changed files with 3 additions and 1 deletions
|
@ -2,6 +2,7 @@ use actix_web::middleware::Logger;
|
||||||
use actix_web::{App, HttpServer};
|
use actix_web::{App, HttpServer};
|
||||||
use rustypaste::config::Config;
|
use rustypaste::config::Config;
|
||||||
use rustypaste::server;
|
use rustypaste::server;
|
||||||
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Result as IoResult;
|
use std::io::Result as IoResult;
|
||||||
|
|
||||||
|
@ -9,7 +10,8 @@ use std::io::Result as IoResult;
|
||||||
async fn main() -> IoResult<()> {
|
async fn main() -> IoResult<()> {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
let config = Config::parse("config").expect("failed to parse config");
|
let config = Config::parse(env::var("CONFIG").as_deref().unwrap_or("config"))
|
||||||
|
.expect("failed to parse config");
|
||||||
let server_config = config.server.clone();
|
let server_config = config.server.clone();
|
||||||
fs::create_dir_all(server_config.upload_path)?;
|
fs::create_dir_all(server_config.upload_path)?;
|
||||||
let mut http_server = HttpServer::new(move || {
|
let mut http_server = HttpServer::new(move || {
|
||||||
|
|
Loading…
Reference in a new issue