aboutsummaryrefslogtreecommitdiff
path: root/src/http.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.rs')
-rw-r--r--src/http.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/http.rs b/src/http.rs
index 05d7440..973e77f 100644
--- a/src/http.rs
+++ b/src/http.rs
@@ -4,6 +4,7 @@ use std::sync::Arc;
use anyhow::Result;
use log::*;
+use futures::future::Future;
use http::uri::Authority;
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request, Response, Server, StatusCode, Uri};
@@ -12,7 +13,11 @@ use crate::consul::Consul;
const CHALLENGE_PREFIX: &str = "/.well-known/acme-challenge/";
-pub async fn serve_http(bind_addr: SocketAddr, consul: Consul) -> Result<()> {
+pub async fn serve_http(
+ bind_addr: SocketAddr,
+ consul: Consul,
+ shutdown_signal: impl Future<Output = ()>,
+) -> Result<()> {
let consul = Arc::new(consul);
// For every connection, we must make a `Service` to handle all
// incoming HTTP requests on said connection.
@@ -30,7 +35,9 @@ pub async fn serve_http(bind_addr: SocketAddr, consul: Consul) -> Result<()> {
});
info!("Listening on http://{}", bind_addr);
- let server = Server::bind(&bind_addr).serve(make_svc);
+ let server = Server::bind(&bind_addr)
+ .serve(make_svc)
+ .with_graceful_shutdown(shutdown_signal);
server.await?;