All instances of `old_io` and `old_path` were switched to use the new shiny `std::io`, `std::net`, and `std::path` modules. This means that `Request` and `Response` implement `Read` and `Write` now. Because of the changes to `TcpListener`, this also takes the opportunity to correct the method usage of `Server`. As with other languages/frameworks, the server is first created with a handler, and then a host/port is passed to a `listen` method. This reverses what `Server` used to do. Closes #347 BREAKING CHANGE: Check the docs. Everything was touched.
		
			
				
	
	
		
			21 lines
		
	
	
		
			491 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			491 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| #![feature(io, net)]
 | |
| extern crate hyper;
 | |
| 
 | |
| use std::io::Write;
 | |
| use std::net::IpAddr;
 | |
| 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_all(PHRASE).unwrap();
 | |
|     res.end().unwrap();
 | |
| }
 | |
| 
 | |
| fn main() {
 | |
|     let _listening = hyper::Server::http(hello)
 | |
|         .listen(IpAddr::new_v4(127, 0, 0, 1), 3000).unwrap();
 | |
|     println!("Listening on http://127.0.0.1:3000");
 | |
| }
 |