Simplified interface
Getty Ritter
10 years ago
| 13 | 13 |
Ok(mut f) => {
|
| 14 | 14 |
let mut s = String::new();
|
| 15 | 15 |
match f.read_to_string(&mut s) {
|
| 16 | |
Ok(_) => callback(s),
|
| 16 |
Ok(_) => callback(s.trim().to_string()),
|
| 17 | 17 |
Err(_) => default,
|
| 18 | 18 |
}
|
| 19 | 19 |
},
|
| 106 | 106 |
|s| s);
|
| 107 | 107 |
let port = with_file(&dir.join("port"),
|
| 108 | 108 |
Ok(80),
|
| 109 | |
|s| s.trim().parse::<u32>() );
|
| 109 |
|s| s.parse::<u32>() );
|
| 110 | 110 |
let port_num = match port {
|
| 111 | 111 |
Ok(n) => n,
|
| 112 | 112 |
Err(e) => return aloys_error(format!("Bad port number in `{:?}: {:?}`", dir, e)),
|
|
| 134 | 134 |
impl Delegate {
|
| 135 | 135 |
fn run(&self, req: &Request, res: Response<Fresh>) {
|
| 136 | 136 |
match self {
|
| 137 | |
&Delegate::Forward(_) => {
|
| 138 | |
let _ = res.send(b"[matched by me!]");
|
| 137 |
&Delegate::Forward(ref fwd) => {
|
| 138 |
let _ = res.send(format!("[forward to {:?}:{:?}]", fwd.domn, fwd.port).as_bytes());
|
| 139 | 139 |
},
|
| 140 | 140 |
&Delegate::Defer(ref rts) => {
|
| 141 | 141 |
rts.dispatch(req, res);
|