Forked from
loposuezo / WebServer
2 commits behind, 17 commits ahead of the upstream repository.
request.rs 682 B
// use std::net::SocketAddr;
use super::{methods::Method, routes::Uri};
type HeaderMap = Vec<String>;
#[derive(Clone)]
pub struct Request<'a> {
pub uri: Uri<'a>,
pub headers: HeaderMap,
pub method: Method,
// pub connection: ConnectionMeta,
}
// struct ConnectionMeta {
// remote: Option<SocketAddr>,
// // certificates
// }
#[derive(Clone, Debug, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum MediaType {
Json,
Plain,
Html,
}
impl Request<'_> {
pub fn can_have_body(&self) -> bool {
match self.method {
Method::Post | Method::Put | Method::Patch | Method::Delete => true,
_ => false,
}
}
}