Stub using Chunk stream in loop_server.
This commit is contained in:
parent
27642f7b14
commit
d0f1cde464
1 changed files with 9 additions and 3 deletions
|
@ -4,16 +4,18 @@ extern crate lab_ebml;
|
||||||
|
|
||||||
use futures::future::FutureResult;
|
use futures::future::FutureResult;
|
||||||
use futures::stream::{iter, Stream};
|
use futures::stream::{iter, Stream};
|
||||||
|
use lab_ebml::chunk::Chunk;
|
||||||
use hyper::{Get, StatusCode};
|
use hyper::{Get, StatusCode};
|
||||||
use hyper::server::{Http, Request, Response, Service};
|
use hyper::server::{Http, Request, Response, Service};
|
||||||
use std::env::args;
|
use std::env::args;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::net::ToSocketAddrs;
|
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;
|
struct WebmServer;
|
||||||
|
|
||||||
type BodyStream = Box<Stream<Item = &'static str, Error = hyper::Error>>;
|
type BodyStream = Box<Stream<Item = Chunk<&'static str>, Error = hyper::Error>>;
|
||||||
|
|
||||||
impl Service for WebmServer {
|
impl Service for WebmServer {
|
||||||
type Request = Request;
|
type Request = Request;
|
||||||
|
@ -23,8 +25,12 @@ impl Service for WebmServer {
|
||||||
fn call(&self, req: Request) -> Self::Future {
|
fn call(&self, req: Request) -> Self::Future {
|
||||||
let response = match (req.method(), req.path()) {
|
let response = match (req.method(), req.path()) {
|
||||||
(&Get, "/loop") => {
|
(&Get, "/loop") => {
|
||||||
let pieces = vec!["<", "Insert WebM stream here.", ">"];
|
let pieces = vec![
|
||||||
let stream: BodyStream = iter(pieces.into_iter().map(|x| Ok(x))).boxed();
|
Chunk::Headers {bytes: Rc::new("<")},
|
||||||
|
Chunk::Headers {bytes: Rc::new("Insert WebM stream here")},
|
||||||
|
Chunk::ClusterBody {bytes: Rc::new(">")}
|
||||||
|
];
|
||||||
|
let stream: BodyStream = Box::new(iter(pieces.into_iter().map(|x| Ok(x))));
|
||||||
Response::new()
|
Response::new()
|
||||||
.with_body(stream)
|
.with_body(stream)
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue