Rocket/examples/stream/src/main.rs

21 lines
422 B
Rust
Raw Normal View History

2016-09-12 09:43:34 +00:00
#![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
use rocket::Rocket;
use rocket::response::{data, Stream};
2016-09-12 09:43:34 +00:00
use std::io::{repeat, Repeat, Read, Take};
type LimitedRepeat = Take<Repeat>;
#[get("/")]
fn root() -> data::Plain<Stream<LimitedRepeat>> {
data::Plain(Stream::from(repeat('a' as u8).take(25000)))
2016-09-12 09:43:34 +00:00
}
fn main() {
Rocket::new("localhost", 8000).mount_and_launch("/", routes![root]);
}