use bytes::Bytes;
#[derive(Debug, Clone)]
pub struct HttpRequest {
pub method: String,
pub path: String,
pub version: HttpVersion,
pub headers: Vec<(String, Vec<u8>)>,
pub body: Bytes,
}
#[derive(Debug, Clone)]
pub struct HttpResponse {
pub status: u16,
pub reason: String,
pub version: HttpVersion,
pub headers: Vec<(String, Vec<u8>)>,
pub body: Bytes,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HttpVersion {
Http1_0,
Http1_1,
}
pub trait HttpHandler: Send + Sync + 'static {
fn on_request(&self, _req: &HttpRequest) {}
fn on_response(&self, _resp: &HttpResponse) {}
}
#[derive(Debug, Clone)]
pub struct HttpConfig {
pub max_buffer: usize,
pub max_headers: usize,
}
impl Default for HttpConfig {
fn default() -> Self {
Self {
max_buffer: 1024 * 1024, max_headers: 64,
}
}
}