use std::future::Future;
use hyper::body::Incoming;
use osproxy_core::EndpointKind;
use crate::request::{IngressRequest, IngressResponse, StreamingResponse};
pub trait IngressHandler: Send + Sync + 'static {
fn handle(&self, req: IngressRequest) -> impl Future<Output = IngressResponse> + Send;
fn forward_plan(&self, _path: &str, _logical_index: &str) -> bool {
false
}
fn handle_forward(
&self,
_req: IngressRequest,
_body: Incoming,
) -> impl Future<Output = StreamingResponse> + Send {
async {
StreamingResponse::buffered(500, br#"{"error":"forward_not_implemented"}"#.to_vec())
}
}
fn wants_search_stream(&self, _endpoint: EndpointKind, _query: Option<&str>) -> bool {
false
}
fn handle_search_stream(
&self,
_req: IngressRequest,
) -> impl Future<Output = StreamingResponse> + Send {
async {
StreamingResponse::buffered(
500,
br#"{"error":"search_stream_not_implemented"}"#.to_vec(),
)
}
}
fn wants_bulk_stream(&self, _endpoint: EndpointKind, _headers: &[(String, String)]) -> bool {
false
}
fn handle_bulk_stream(
&self,
_req: IngressRequest,
_body: Incoming,
) -> impl Future<Output = IngressResponse> + Send {
async { IngressResponse::json(500, br#"{"error":"bulk_stream_not_implemented"}"#.to_vec()) }
}
}