Skip to main content

load_http_handler

Function load_http_handler 

Source
pub fn load_http_handler(
    server: &mut Server,
    listener: &Listener,
    pipeline: Arc<ArcSwap<FilterPipeline>>,
    cert_watcher_shutdowns: &mut Vec<Sender<bool>>,
) -> Result<(), ProxyError>
Expand description

Load an HTTP handler for a single listener.

Any TLS certificate watcher shutdown senders are appended to cert_watcher_shutdowns. The caller must keep this Vec alive until server shutdown; dropping the senders signals the watcher tasks to stop.

ⓘ
use std::sync::Arc;

use pingora_core::server::Server;
use praxis_core::config::Listener;
use praxis_filter::{FilterPipeline, FilterRegistry};
use praxis_protocol::http::pingora::handler::load_http_handler;

let mut server = Server::new(None).unwrap();
server.bootstrap();
let registry = FilterRegistry::with_builtins();
let pipeline = Arc::new(FilterPipeline::build(&mut [], &registry).unwrap());
let listener = Listener {
    name: "http".into(),
    address: "127.0.0.1:8080".into(),
    cluster: None,
    downstream_read_timeout_ms: None,
    filter_chains: vec![],
    max_connections: None,
    protocol: Default::default(),
    tcp_session_timeout_ms: None,
    tcp_max_duration_secs: None,
    tls: None,
    upstream: None,
};
let mut shutdowns = Vec::new();
load_http_handler(&mut server, &listener, pipeline, &mut shutdowns).unwrap();

§Errors

Returns ProxyError if the listener fails to bind.