2019-06-19 06:20:50 +02:00
|
|
|
pub mod configuration;
|
|
|
|
pub mod configuration_two;
|
|
|
|
pub mod directory;
|
2019-06-26 10:27:25 +02:00
|
|
|
|
2019-06-17 23:35:47 +02:00
|
|
|
// <individual-file>
|
|
|
|
use actix_files::NamedFile;
|
2019-06-28 19:31:30 +02:00
|
|
|
use actix_web::{HttpRequest, Result};
|
2019-06-17 23:35:47 +02:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
fn index(req: HttpRequest) -> Result<NamedFile> {
|
2019-06-26 10:27:25 +02:00
|
|
|
let path: PathBuf = req.match_info().query("filename").parse().unwrap();
|
2019-06-17 23:35:47 +02:00
|
|
|
Ok(NamedFile::open(path)?)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-06-28 19:31:30 +02:00
|
|
|
use actix_web::{web, App, HttpServer};
|
|
|
|
|
2019-06-26 10:27:25 +02:00
|
|
|
HttpServer::new(|| App::new().route("/{filename:.*}", web::get().to(index)))
|
|
|
|
.bind("127.0.0.1:8088")
|
|
|
|
.unwrap()
|
|
|
|
.run()
|
|
|
|
.unwrap();
|
2019-06-17 23:35:47 +02:00
|
|
|
}
|
|
|
|
// </individual-file>
|