fn http_listener(
    addr: SocketAddr,
    history: OriginsHistory,
) -> impl Future<Item=(), Error=()> {
    TcpListener::bind(&addr).into_future()
    .then(move |res| {
        match res {
            Ok(some) => {
                info!("HTTP monitor: Listening on {}.", addr);
                Ok(some)
            }
            Err(err) => {
                error!("Failed to bind HTTP monitor to {}: {}", addr, err);
                Err(())
            }
        }
    })
    .and_then(move |listener| {
        listener.incoming()
        .map_err(|err| {
            error!("Failed to accept HTTP monitor connection: {}", err)
        })
        .for_each(move |sock| {
            tokio::spawn(
                HttpConnection::new(sock, history.clone())
            )
        })
    })
}
/// Returns a future for a single HTTP listener.
///
/// The future will never resolve unless an error happens that breaks the
/// listener, in which case it will print an error and resolve the error case.
/// It will listen on `addr` for incoming connection. Each new connection will
/// be handled via a brand new `HttpConnection`.
Returns a future for a single HTTP listener.
The future will never resolve unless an error happens that breaks the
listener, in which case it will print an error and resolve the error case.
It will listen on `addr` for incoming connection. Each new connection will
be handled via a brand new `HttpConnection`.
Returns a future for a single HTTP listener . The future will never resolve unless an error happens that breaks the listener in which case it will print an error and resolve the error case . It will listen on ` addr ` for incoming connection . Each new connection will be handled via a brand new ` HttpConnection ` .
fn http_listener(
    addr: SocketAddr,
    history: OriginsHistory,
) -> impl Future<Item=(), Error=()> {
    TcpListener::bind(&addr).into_future()
    .then(move |res| {
        match res {
            Ok(some) => {
                info!("HTTP monitor: Listening on {}.", addr);
                Ok(some)
            }
            Err(err) => {
                error!("Failed to bind HTTP monitor to {}: {}", addr, err);
                Err(())
            }
        }
    })
    .and_then(move |listener| {
        listener.incoming()
        .map_err(|err| {
            error!("Failed to accept HTTP monitor connection: {}", err)
        })
        .for_each(move |sock| {
            tokio::spawn(
                HttpConnection::new(sock, history.clone())
            )
        })
    })
}
fn http_listener ( addr : SocketAddr , history : OriginsHistory , ) -> impl Future < Item = ( ) , Error = ( ) > { TcpListener :: bind ( & addr ) . into_future ( ) . then ( move | res | { match res { Ok ( some ) => { info ! ( " " addr ) ; Ok ( some ) } Err ( err ) => { error ! ( " " addr err ) ; Err ( ( ) ) } } } ) . and_then ( move | listener | { listener . incoming ( ) . map_err ( | err | { error ! ( " " err ) } ) . for_each ( move | sock | { tokio :: spawn ( HttpConnection :: new ( sock , history . clone ( ) ) ) } ) } ) }
Returns a future for a single HTTP listener.
Returns a future for a single HTTP listener .
addr
SocketAddr
history
OriginsHistory
addr
SocketAddr
history
OriginsHistory