Have stub server recognize a URL path
This commit is contained in:
parent
6f80da4735
commit
ef45728779
1 changed files with 13 additions and 3 deletions
|
@ -3,12 +3,12 @@ extern crate hyper;
|
|||
extern crate lab_ebml;
|
||||
|
||||
use futures::future::FutureResult;
|
||||
use hyper::StatusCode;
|
||||
use hyper::{Get, StatusCode};
|
||||
use hyper::server::{Http, Request, Response, Service};
|
||||
use std::env::args;
|
||||
use std::net::ToSocketAddrs;
|
||||
|
||||
const SRC_FILE: &'static [u8] = include_bytes!("../data/test1.webm");
|
||||
//const SRC_FILE: &'static [u8] = include_bytes!("../data/test1.webm");
|
||||
|
||||
struct WebmServer;
|
||||
|
||||
|
@ -18,7 +18,17 @@ impl Service for WebmServer {
|
|||
type Error = hyper::Error;
|
||||
type Future = FutureResult<Response, hyper::Error>;
|
||||
fn call(&self, req: Request) -> Self::Future {
|
||||
futures::future::ok(Response::new().with_status(StatusCode::NotFound))
|
||||
let response = match (req.method(), req.path()) {
|
||||
(&Get, "/loop") => {
|
||||
Response::new()
|
||||
.with_body("<Insert WebM stream here>")
|
||||
},
|
||||
_ => {
|
||||
Response::new()
|
||||
.with_status(StatusCode::NotFound)
|
||||
}
|
||||
};
|
||||
futures::future::ok(response)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue