1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#![deny(warnings)]
extern crate rustc_serialize;
#[macro_use]
extern crate router;
extern crate bodyparser;
extern crate persistent;
extern crate logger;
extern crate iron;
extern crate iron_hmac;
extern crate hyper;
#[macro_use]
extern crate log;
extern crate racer;
extern crate rand;
pub mod util;
pub mod http;
pub mod engine;
use std::io::Read;
use std::fs::File;
#[derive(Debug, Default)]
pub struct Config {
pub port: u16,
pub secret_file: Option<String>,
pub print_http_logs: bool,
pub rust_src_path: Option<String>
}
impl Config {
pub fn new() -> Config {
Default::default()
}
pub fn read_secret_file(&self) -> String {
self.secret_file.as_ref().map(|secret_file_path| {
let buf = {
let mut f = File::open(secret_file_path).unwrap();
let mut buf = String::new();
f.read_to_string(&mut buf).unwrap();
buf
};
::std::fs::remove_file(secret_file_path).unwrap();
buf
}).unwrap()
}
}