httptin 0.2.3

httpbin like utility rewrite in Rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use hyper::status::StatusCode;

use makeresponse::MakeResponse;

impl MakeResponse for StatusCode {
    fn status(&self) -> StatusCode {
        *self
    }
}

pub fn status(path: &str) -> StatusCode {
    match path.trim_left_matches("/status/").parse::<u16>() {
        Ok(status) => StatusCode::from_u16(status),
        Err(_) => StatusCode::BadRequest,
    }
}