/* This file is part of gnix (https://codeberg.org/metamuffin/gnix) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin */ use super::{Node, NodeContext, NodeKind, NodeRequest, NodeResponse}; use crate::{config::DynNode, error::ServiceError}; use anyhow::Result; use futures::Future; use log::debug; use serde::Deserialize; use std::{pin::Pin, sync::Arc}; pub struct InspectKind; #[derive(Deserialize)] pub struct Inspect { next: DynNode, } impl NodeKind for InspectKind { fn name(&self) -> &'static str { "inspect" } fn instanciate(&self, config: serde_yml::Value) -> Result> { Ok(Arc::new(serde_yml::from_value::(config)?)) } } impl Node for Inspect { fn handle<'a>( &'a self, context: &'a mut NodeContext, request: NodeRequest, ) -> Pin> + Send + Sync + 'a>> { Box::pin(async move { debug!( "address: {:?}\nversion: {:?}\nuri: {:?}\nheaders: {:#?}", context.addr, request.version(), request.uri(), request.headers(), ); self.next.handle(context, request).await }) } }