Files
hyper/examples/hello.rs
Sean McArthur f7124bb8e2 rustup: sweeping fixes for all the changes in 1.0-alpha
- Some switches to u64 instead of usize
- For now, allow(unstable)
- use associated types for all the Network stuff
2015-01-10 21:29:27 -08:00

19 lines
444 B
Rust

#![allow(unstable)]
extern crate hyper;
use std::io::net::ip::Ipv4Addr;
use hyper::server::{Request, Response};
static PHRASE: &'static [u8] = b"Hello World!";
fn hello(_: Request, res: Response) {
let mut res = res.start().unwrap();
res.write(PHRASE).unwrap();
res.end().unwrap();
}
fn main() {
hyper::Server::http(Ipv4Addr(127, 0, 0, 1), 3000).listen(hello).unwrap();
println!("Listening on http://127.0.0.1:3000");
}