#![feature(plugin)] #![plugin(rocket_codegen)] extern crate rocket; use rocket::response::{data, Stream}; use std::io::{self, repeat, Repeat, Read, Take}; use std::fs::File; type LimitedRepeat = Take; #[get("/")] fn root() -> data::Plain> { data::Plain(Stream::from(repeat('a' as u8).take(25000))) } #[get("/big_file")] fn file() -> io::Result> { // Generate this file using: head -c BYTES /dev/random > big_file.dat const FILENAME: &'static str = "big_file.dat"; File::open(FILENAME).map(|file| Stream::from(file)) } fn main() { rocket::ignite().mount("/", routes![root, file]).launch(); }