This commit is contained in:
2020-12-18 20:51:36 +01:00
parent 8b414ad669
commit 3091529899
2 changed files with 67 additions and 5 deletions

View File

@@ -30,11 +30,11 @@ use std::path::Path;
use std::sync::Arc;
use std::sync::Mutex;
const STORAGE_DIR: &str = "./snips";
lazy_static! {
static ref STORAGE_DIR: String =
env::var("BROWNPAPER_STORAGE_DIR").unwrap_or("/snips".to_string());
static ref KNOWN_KEYS: Arc<Mutex<KnownKeys>> = Arc::new(Mutex::new(
KnownKeys::load_dir([STORAGE_DIR, "keys"].join("/")).expect("Failed to load pubkeys")
KnownKeys::load_dir([&*STORAGE_DIR, "keys"].join("/")).expect("Failed to load pubkeys")
));
}
@@ -42,7 +42,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
fn handle(req: &mut Request) -> IronResult<Response> {
println!("{}", req.url);
let storage = SnippetStorage::new(&Path::new(&STORAGE_DIR));
let storage = SnippetStorage::new(&Path::new(&*STORAGE_DIR));
let segments: Vec<&str> = req.url.path();
match (&req.method, segments.first()) {
(Method::Get, Some(&"version")) => Ok(Response::with((iron::status::Ok, VERSION))),
@@ -124,7 +124,7 @@ fn handle(req: &mut Request) -> IronResult<Response> {
fn main() {
let chain = Chain::new(handle);
println!("Starting brownpaper: {}", STORAGE_DIR);
println!("Starting brownpaper: {}", &*STORAGE_DIR);
Iron::new(chain).http(
args()
.skip(1)