some comments
This commit is contained in:
parent
aafef1b776
commit
05f1b5fe5e
@ -1,6 +1,8 @@
|
|||||||
# EzHttp
|
# EzHttp
|
||||||
Easy http server on rust
|
Easy http server on rust
|
||||||
|
|
||||||
|
This library is under developement, so if you found any bugs, please write them to [Issues](https://github.com/MeexReay/ezhttp/issues)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```rust
|
```rust
|
||||||
use ezhttp::{Headers, HttpRequest, HttpResponse, HttpServer};
|
use ezhttp::{Headers, HttpRequest, HttpResponse, HttpServer};
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -10,12 +10,12 @@ impl HttpServer for EzSite {
|
|||||||
|
|
||||||
if req.page == "/" {
|
if req.page == "/" {
|
||||||
Some(HttpResponse::from_str(
|
Some(HttpResponse::from_str(
|
||||||
Headers::from(vec![("Content-Type", "text/html")]),
|
Headers::from(vec![("Content-Type", "text/html")]), // response headers
|
||||||
"200 OK".to_string(),
|
"200 OK".to_string(), // response status code
|
||||||
&self.index_page,
|
&self.index_page, // response body
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None // just shutdown socket
|
None // shutdown request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,4 +41,6 @@ fn main() {
|
|||||||
let host = "localhost:8080";
|
let host = "localhost:8080";
|
||||||
|
|
||||||
ezhttp::start_server(site, host).unwrap();
|
ezhttp::start_server(site, host).unwrap();
|
||||||
|
|
||||||
|
// ezhttp::start_server_timeout(site, host, Duration::from_secs(5)).unwrap(); // with read and write timeout
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user