mod.nix
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -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)
|
||||
|
Reference in New Issue
Block a user