Internals have been shuffled around such that Request and Reponse are now given only a mutable reference to the stream, instead of being allowed to consume it. This allows the server to re-use the streams if keep-alive is true. A task pool is used, and the number of the threads can currently be adjusted by using the `listen_threads()` method on Server. [breaking-change]
		
			
				
	
	
		
			17 lines
		
	
	
		
			372 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			372 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| 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();
 | |
| }
 |