1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 02:19:22 +02:00

update example

This commit is contained in:
Nikolay Kim
2018-01-28 01:04:58 -08:00
parent 7c7743c145
commit 55b2fb7f77
7 changed files with 68 additions and 44 deletions

View File

@ -477,8 +477,10 @@ impl<T, A, H, U, V> HttpServer<WrapperStream<T>, A, H, U>
// start server
let signals = self.subscribe_to_signals();
let addr: SyncAddress<_> = HttpServer::create(move |ctx| {
ctx.add_stream(stream.map(
move |(t, _)| Conn{io: WrapperStream::new(t), peer: None, http2: false}));
ctx.add_message_stream(
stream
.map_err(|_| ())
.map(move |(t, _)| Conn{io: WrapperStream::new(t), peer: None, http2: false}));
self
});
signals.map(|signals| signals.send(
@ -542,6 +544,22 @@ impl<T, A, H, U, V> Handler<io::Result<Conn<T>>> for HttpServer<T, A, H, U>
}
}
impl<T, A, H, U, V> Handler<Conn<T>> for HttpServer<T, A, H, U>
where T: IoStream,
H: HttpHandler + 'static,
U: IntoIterator<Item=V> + 'static,
V: IntoHttpHandler<Handler=H>,
A: 'static,
{
type Result = ();
fn handle(&mut self, msg: Conn<T>, _: &mut Context<Self>) -> Self::Result {
Arbiter::handle().spawn(
HttpChannel::new(
Rc::clone(self.h.as_ref().unwrap()), msg.io, msg.peer, msg.http2));
}
}
impl<T, A, H, U, V> Handler<PauseServer> for HttpServer<T, A, H, U>
where T: IoStream,
H: HttpHandler + 'static,