use crate::body::Body; use hyper::{Response, StatusCode}; use std::fs::File; use std::io::Read; pub(crate) fn get_static(file: &String) -> Response { let file = read_static(file); match file { Ok(file) => Response::new(Body::new(file)), Err(_) => Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) .body(Body::Empty) .unwrap(), } } pub(crate) fn get_rendered(file: &String) -> Response { todo!() } fn read_static(file: &String) -> Result, Box> { let mut buf = Vec::new(); let mut file = File::open(file)?; file.read_to_end(&mut buf)?; Ok(buf) }