1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 09:59:21 +02:00

http server accepts factory of HttpHandlers

This commit is contained in:
Nikolay Kim
2017-12-12 07:40:36 -08:00
parent b9da09ddf0
commit e9aa67b75d
9 changed files with 34 additions and 31 deletions

View File

@ -55,10 +55,10 @@ request handler with the application's `resource` on a particular *HTTP method*
```
After that, application instance can be used with `HttpServer` to listen for incoming
connections:
connections. Server accepts function that should return `HttpHandler` instance:
```rust,ignore
HttpServer::new(app).serve::<_, ()>("127.0.0.1:8088");
HttpServer::new(|| app).serve::<_, ()>("127.0.0.1:8088");
```
That's it. Now, compile and run the program with cargo run.
@ -79,7 +79,7 @@ fn main() {
let sys = actix::System::new("example");
HttpServer::new(
Application::new()
|| Application::new()
.resource("/", |r| r.f(index)))
.serve::<_, ()>("127.0.0.1:8088").unwrap();

View File

@ -42,7 +42,7 @@ Multiple applications could be served with one server:
use actix_web::*;
fn main() {
HttpServer::<TcpStream, SocketAddr, _>::new(vec![
HttpServer::<TcpStream, SocketAddr, _>::new(|| vec![
Application::new()
.prefix("/app1")
.resource("/", |r| r.f(|r| httpcodes::HTTPOk)),

View File

@ -81,7 +81,7 @@ fn main() {
let sys = actix::System::new("example");
HttpServer::new(
Application::new()
|| Application::new()
.resource("/", |r| r.method(Method::GET).f(index)))
.serve::<_, ()>("127.0.0.1:8088").unwrap();