Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
hkws committed Nov 30, 2021
1 parent 8c103cf commit 8dcce1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ tokio = { version = "1.14.0", features = ["rt", "time"] }
[dev-dependencies]
actix-web = "4.0.0-beta.12"
futures-util = "0.3.12"
actix-files = "0.5.0"
actix-files = "0.6.0-beta.9"
env_logger = "0.7"
actix-cors = "0.5.3"
8 changes: 4 additions & 4 deletions examples/actix-web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub struct RequestUser {
impl FromRequest for RequestUser {
type Error = Error;
type Future = Ready<Result<Self, Self::Error>>;
type Config = ();

fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future {
let token = match req.headers().get("Authorization") {
Expand Down Expand Up @@ -68,9 +67,10 @@ async fn uid(user: RequestUser) -> impl Responder {
}

#[get("/{file}")]
async fn index(web::Path(file): web::Path<String>) -> Result<NamedFile> {
let path: PathBuf = fs::canonicalize(format!("./examples/statics/{}", file)).unwrap();
Ok(NamedFile::open(path)?)
async fn index(path: web::Path<String>) -> impl Responder {
let filepath = path.into_inner();
let file: PathBuf = fs::canonicalize(format!("./examples/statics/{}", filepath)).unwrap();
NamedFile::open_async(file).await
}

#[actix_web::main]
Expand Down

0 comments on commit 8dcce1a

Please sign in to comment.