Modify method of getting arguments
It may be inefficient, I dont know another way to do so easily.
This commit is contained in:
parent
680dc9d0fc
commit
88dfaed1a0
@ -17,7 +17,6 @@ use actix_web::{
|
||||
use crate::router::global;
|
||||
use json::JsonValue;
|
||||
use clap::Parser;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
fn unhandled(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
if body != String::new() {
|
||||
@ -215,12 +214,15 @@ pub struct Args {
|
||||
https: bool
|
||||
}
|
||||
|
||||
pub fn get_args() -> Args {
|
||||
Args::parse()
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
let args = Args::parse();
|
||||
let args = get_args();
|
||||
let port = args.port;
|
||||
|
||||
router::gree::HTTPS.store(args.https, Ordering::Relaxed);
|
||||
let rv = HttpServer::new(|| App::new()
|
||||
.wrap_fn(|req, srv| {
|
||||
println!("Request: {}", req.path());
|
||||
|
@ -7,8 +7,6 @@ use json::{object, JsonValue};
|
||||
use hmac::{Hmac, Mac};
|
||||
use rusqlite::params;
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
use openssl::pkey::PKey;
|
||||
use openssl::rsa::Rsa;
|
||||
@ -333,12 +331,9 @@ pub fn migration_password_register(req: HttpRequest, body: String) -> HttpRespon
|
||||
send(req, resp)
|
||||
}
|
||||
|
||||
lazy_static!{
|
||||
pub static ref HTTPS: AtomicBool = AtomicBool::new(false);
|
||||
}
|
||||
|
||||
pub fn get_protocol() -> String {
|
||||
if HTTPS.load(Ordering::SeqCst) == true {
|
||||
let args = crate::get_args();
|
||||
if args.https == true {
|
||||
return String::from("https");
|
||||
}
|
||||
String::from("http")
|
||||
|
@ -1,7 +1,6 @@
|
||||
use rusqlite::{Connection, params, ToSql};
|
||||
use std::sync::Mutex;
|
||||
use json::{JsonValue, array};
|
||||
use clap::Parser;
|
||||
use std::fs;
|
||||
|
||||
use crate::router::clear_rate::Live;
|
||||
@ -13,7 +12,7 @@ pub struct SQLite {
|
||||
|
||||
impl SQLite {
|
||||
pub fn new(path: &str, setup: fn(&SQLite)) -> SQLite {
|
||||
let args = crate::Args::parse();
|
||||
let args = crate::get_args();
|
||||
fs::create_dir_all(&args.path).unwrap();
|
||||
let conn = Connection::open(format!("{}/{}", args.path, path)).unwrap();
|
||||
conn.execute("PRAGMA foreign_keys = ON;", ()).unwrap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user