Working services
This commit is contained in:
parent
81e647e881
commit
3370760891
1 changed files with 19 additions and 3 deletions
|
@ -46,6 +46,22 @@ impl Service<Request> for Echo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Charlie;
|
||||||
|
impl<'a> Service<&'a AddrStream> for Charlie {
|
||||||
|
type Response = Echo;
|
||||||
|
type Error = anyhow::Error;
|
||||||
|
type Future = Pin<Box<dyn futures::Future<Output = Result<Self::Response>> + Send>>;
|
||||||
|
|
||||||
|
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
|
||||||
|
Poll::Ready(Ok(()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn call(&mut self, addr: &'a AddrStream) -> Self::Future {
|
||||||
|
println!("{}, {}", addr.remote_addr, addr.local_addr);
|
||||||
|
let fut = futures::future::ok(Echo);
|
||||||
|
Box::pin(fut)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
pub fn new(config: Config) -> Result<Arc<Self>> {
|
pub fn new(config: Config) -> Result<Arc<Self>> {
|
||||||
|
@ -73,18 +89,18 @@ impl Server {
|
||||||
let incoming = AddrIncoming::new("127.0.0.1:4567").await?;
|
let incoming = AddrIncoming::new("127.0.0.1:4567").await?;
|
||||||
|
|
||||||
|
|
||||||
let make_service = tower::service_fn(|addr: &AddrStream| {
|
/*let make_service = tower::service_fn(|addr: &AddrStream| {
|
||||||
tracing::debug!(remote_addr = %addr.remote_addr, local_addr = %addr.local_addr, "accept");
|
tracing::debug!(remote_addr = %addr.remote_addr, local_addr = %addr.local_addr, "accept");
|
||||||
//let service = tower::ServiceBuilder::new().service_fn(handle_req);
|
//let service = tower::ServiceBuilder::new().service_fn(handle_req);
|
||||||
//let service = tower::service_fn(handle_req);
|
//let service = tower::service_fn(handle_req);
|
||||||
let service = Echo;
|
let service = Echo;
|
||||||
futures::future::ok::<_, std::convert::Infallible>(service)
|
futures::future::ok::<_, std::convert::Infallible>(service)
|
||||||
//service
|
//service
|
||||||
});
|
});*/
|
||||||
|
|
||||||
|
|
||||||
//println!("{:?}", make_service);
|
//println!("{:?}", make_service);
|
||||||
let server = ImapServer::new(incoming).serve(make_service);
|
let server = ImapServer::new(incoming).serve(Charlie);
|
||||||
let _ = server.await?;
|
let _ = server.await?;
|
||||||
|
|
||||||
/*let creds = self.login_provider.login("quentin", "poupou").await?;
|
/*let creds = self.login_provider.login("quentin", "poupou").await?;
|
||||||
|
|
Loading…
Reference in a new issue