1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 07:29:02 +02:00
This commit is contained in:
Rob Ede
2020-09-12 16:21:54 +01:00
committed by GitHub
parent a0ce9f28e2
commit 4d8d53cea5
145 changed files with 1011 additions and 1461 deletions

View File

@ -4,7 +4,6 @@ version = "1.0.0"
edition = "2018"
[dependencies]
actix-web = "2.0"
actix-rt = "1.0"
actix-files = "0.2"
mime = "*"
actix-web = "3"
actix-files = "0.3"
mime = "0.3"

View File

@ -1,8 +1,9 @@
// <config-one>
use actix_files as fs;
use actix_web::http::header::{ContentDisposition, DispositionType};
use actix_web::{web, App, Error, HttpRequest, HttpServer};
use actix_web::{get, App, Error, HttpRequest, HttpServer};
#[get("/{filename:.*}")]
async fn index(req: HttpRequest) -> Result<fs::NamedFile, Error> {
let path: std::path::PathBuf = req.match_info().query("filename").parse().unwrap();
let file = fs::NamedFile::open(path)?;
@ -14,10 +15,10 @@ async fn index(req: HttpRequest) -> Result<fs::NamedFile, Error> {
}))
}
#[actix_rt::main]
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| App::new().route("/{filename:.*}", web::get().to(index)))
.bind("127.0.0.1:8088")?
HttpServer::new(|| App::new().service(index))
.bind("127.0.0.1:8080")?
.run()
.await
}

View File

@ -2,7 +2,7 @@
use actix_files as fs;
use actix_web::{App, HttpServer};
#[actix_rt::main]
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(
@ -11,7 +11,7 @@ async fn main() -> std::io::Result<()> {
.use_last_modified(true),
)
})
.bind("127.0.0.1:8088")?
.bind("127.0.0.1:8080")?
.run()
.await
}

View File

@ -2,12 +2,12 @@
use actix_files as fs;
use actix_web::{App, HttpServer};
#[actix_rt::main]
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(fs::Files::new("/static", ".").show_files_listing())
})
.bind("127.0.0.1:8088")?
.bind("127.0.0.1:8080")?
.run()
.await
}

View File

@ -12,12 +12,12 @@ async fn index(req: HttpRequest) -> Result<NamedFile> {
Ok(NamedFile::open(path)?)
}
#[actix_rt::main]
#[actix_web::main]
async fn main() -> std::io::Result<()> {
use actix_web::{web, App, HttpServer};
HttpServer::new(|| App::new().route("/{filename:.*}", web::get().to(index)))
.bind("127.0.0.1:8088")?
.bind("127.0.0.1:8080")?
.run()
.await
}