http-salient 0.1.1

Simple http webserver
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::{fs, path::Path};

use crate::response::{Response, OK_STATUS};

#[derive(Clone)]
pub struct Page {
    pub path: String,
    pub response: Response,
}

impl Page {
    pub fn new(location: &Path) -> Self {
        let path = location.to_str().unwrap().split("www").nth(1).unwrap();
        let path = "./www".to_owned() + path;
        let response: Response = Response::new(fs::read_to_string(location).unwrap(), OK_STATUS);
        Page { path, response }
    }
}