mirror of
https://github.com/actix/actix-website
synced 2024-12-04 04:31:55 +01:00
28 lines
755 B
Rust
28 lines
755 B
Rust
|
// <config-one>
|
||
|
// extern crate actix_web;
|
||
|
// extern crate mime;
|
||
|
// use actix_files::{FileConfig, NamedFile};
|
||
|
// use actix_web::http::header::DispositionType;
|
||
|
// use actix_web::{http::Method, App, HttpRequest, Result};
|
||
|
|
||
|
// use std::path::PathBuf;
|
||
|
|
||
|
// #[derive(Default)]
|
||
|
// struct MyConfig;
|
||
|
|
||
|
// impl FileConfig for MyConfig {
|
||
|
// fn content_disposition_map(typ: mime::Name) -> DispositionType {
|
||
|
// DispositionType::Attachment
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// fn index(req: &HttpRequest) -> Result<NamedFile<MyConfig>> {
|
||
|
// let path: PathBuf = req.match_info().query("tail")?;
|
||
|
// Ok(NamedFile::open_with_config(path, MyConfig)?)
|
||
|
// }
|
||
|
|
||
|
// fn main() {
|
||
|
// App::new().resource(r"/a/{tail:.*}", |r| r.method(Method::GET).f(index));
|
||
|
// }
|
||
|
// </config-one>
|