use std::sync::Arc;
use praxis_core::{
PingoraServerRuntime, ProxyError,
config::{Config, ProtocolKind},
};
use crate::{ListenerPipelines, Protocol};
pub mod context;
pub(crate) mod convert;
pub mod handler;
pub mod health;
#[cfg(feature = "admin-api")]
pub(crate) mod json;
#[cfg(feature = "admin-api")]
pub mod kv;
pub mod listener;
pub mod metrics;
pub struct PingoraHttp;
impl Protocol for PingoraHttp {
fn register(
self: Box<Self>,
server: &mut PingoraServerRuntime,
config: &Config,
pipelines: &ListenerPipelines,
) -> Result<Vec<tokio::sync::watch::Sender<bool>>, ProxyError> {
let http_listeners: Vec<_> = config
.listeners
.iter()
.filter(|l| l.protocol == ProtocolKind::Http)
.collect();
if http_listeners.is_empty() {
return Ok(Vec::new());
}
let mut cert_watcher_shutdowns = Vec::new();
for listener in &http_listeners {
let pipeline = pipelines.get(&listener.name).map(Arc::clone).ok_or_else(|| {
ProxyError::Config(format!("no pipeline for listener '{name}'", name = listener.name))
})?;
handler::load_http_handler(server.server_mut(), listener, pipeline, &mut cert_watcher_shutdowns)?;
}
Ok(cert_watcher_shutdowns)
}
}