Get rid of lifetime on Service

This commit is contained in:
Brian Picciano 2023-06-18 15:10:06 +02:00
parent 1f9ae0038f
commit 7ea97b2617
2 changed files with 8 additions and 8 deletions

View File

@ -14,20 +14,20 @@ use crate::{domain, origin, service};
type SvcResponse = Result<Response<hyper::body::Body>, String>;
#[derive(Clone)]
pub struct Service<'svc> {
pub struct Service {
domain_manager: sync::Arc<dyn domain::manager::Manager>,
target_a: net::Ipv4Addr,
passphrase: String,
http_domain: domain::Name,
handlebars: handlebars::Handlebars<'svc>,
handlebars: handlebars::Handlebars<'static>,
}
pub fn new<'svc>(
pub fn new(
domain_manager: sync::Arc<dyn domain::manager::Manager>,
target_a: net::Ipv4Addr,
passphrase: String,
http_domain: domain::Name,
) -> Service<'svc> {
) -> Service {
Service {
domain_manager,
target_a,
@ -59,7 +59,7 @@ struct DomainSyncArgs {
passphrase: String,
}
impl<'svc> Service<'svc> {
impl<'svc> Service {
fn serve_string(&self, status_code: u16, path: &'_ str, body: Vec<u8>) -> SvcResponse {
let content_type = mime_guess::from_path(path)
.first_or_octet_stream()
@ -307,7 +307,7 @@ impl<'svc> Service<'svc> {
}
pub async fn handle_request(
svc: sync::Arc<Service<'_>>,
svc: sync::Arc<Service>,
req: Request<Body>,
) -> Result<Response<Body>, Infallible> {
match handle_request_inner(svc, req).await {
@ -323,7 +323,7 @@ fn strip_port(host: &str) -> &str {
}
}
pub async fn handle_request_inner(svc: sync::Arc<Service<'_>>, req: Request<Body>) -> SvcResponse {
pub async fn handle_request_inner(svc: sync::Arc<Service>, req: Request<Body>) -> SvcResponse {
let maybe_host = match (
req.headers()
.get("Host")

View File

@ -5,7 +5,7 @@ use handlebars::Handlebars;
#[prefix = "/"]
struct Dir;
pub fn get<'hbs>() -> Handlebars<'hbs> {
pub fn get() -> Handlebars<'static> {
let mut reg = Handlebars::new();
reg.register_embed_templates::<Dir>()
.expect("registered embedded templates");