read_diff_dir

Function read_diff_dir 

Source
pub fn read_diff_dir<S>(parent_dir: S) -> impl Fn(Request, Response<'_>)
where S: Into<String> + Clone,
Expand description

Read a file from the directory different than the one specified during the handler’s creation

§Example:

use oak_http_server::{handlers::read_diff_dir, Server};

fn main() {
    let hostname = "localhost";
    let port: u16 = 2300;

    let mut server = Server::new(hostname, port);
	// If the server were to be started, any content the server would provide for the `/www` directory would be readen from the local `etc` directory
    server.on_directory("/www", read_diff_dir("etc"));
}