Skip to content
Snippets Groups Projects
Forked from loposuezo / WebServer
2 commits behind, 10 commits ahead of the upstream repository.
request.rs 635 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)]
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,
        }
    }
}