use crate::headers::Headers;
use crate::path::PathData;
use crate::path::path_regex::Params;
use crate::query::QueryData;
#[derive(Debug)]
pub struct Request {
pub method: String,
pub path: String,
pub pathname: String,
pub params: Params,
pub querystring: String,
pub query: QueryData,
pub version: String,
pub headers: Headers,
pub body: String,
}
impl From<Vec<String>> for Request {
fn from(value: Vec<String>) -> Self {
let heading_info = value[0].split(' ').collect::<Vec<&str>>();
let PathData {
path,
pathname,
querystring,
query,
} = PathData::new(heading_info[1]);
let body = "".to_string();
Request {
method: heading_info[0].to_string(),
version: heading_info[2].to_string(),
path,
pathname,
params: Params::new(),
query,
querystring,
headers: Headers::from(&value[1..]),
body,
}
}
}