Page abstraction
This commit is contained in:
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user