Page abstraction
All checks were successful
CI / Check typos (push) Successful in 10s
CI / Check links (push) Successful in 34s
CI / Clippy (push) Successful in 41s
CI / Build and test (push) Successful in 2m4s
CI / Build container (push) Successful in 3m15s

This commit is contained in:
2025-11-04 08:55:14 -08:00
parent acc057e4cb
commit 4504a88f4b
20 changed files with 522 additions and 233 deletions

View File

@@ -1,9 +1,7 @@
use anyhow::{Context, Result};
use axum::{extract::connect_info::Connected, serve::IncomingStream};
use libservice::{Service, ToService};
use libservice::{Service, ServiceConnectInfo, ToService};
use service_webpage::WebpageService;
use std::{net::SocketAddr, sync::Arc};
use tokio::net::TcpListener;
use std::sync::Arc;
use tracing::{error, info};
use crate::CmdContext;
@@ -25,7 +23,7 @@ impl ServeArgs {
.context("while building service")?
.make_router()
.expect("service must be initialized")
.into_make_service_with_connect_info::<ServerConnectInfo>();
.into_make_service_with_connect_info::<ServiceConnectInfo>();
let listener = match tokio::net::TcpListener::bind(self.addr.clone()).await {
Ok(x) => x,
@@ -75,19 +73,3 @@ pub async fn make_service(_state: Option<Arc<RouterState>>) -> Result<impl ToSer
Ok(Service::new().merge(service_webpage).to_service().trace())
}
#[derive(Clone, Debug)]
pub struct ServerConnectInfo {
#[expect(dead_code)]
pub addr: Arc<SocketAddr>,
}
impl Connected<IncomingStream<'_, TcpListener>> for ServerConnectInfo {
fn connect_info(target: IncomingStream<'_, TcpListener>) -> Self {
let addr = target.remote_addr();
Self {
addr: Arc::new(*addr),
}
}
}