1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-23 15:51:06 +01:00

stop cloning request across service call (#213)

This commit is contained in:
Rob Ede 2021-12-13 02:49:27 +00:00 committed by GitHub
parent a0c93c62b3
commit 0805f2b1c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 19 deletions

View File

@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx
## 0.6.0-beta.6 - 2021-12-13
* Fix panic when wrapping routes with dynamic segments in their paths. [#213]
[#213]: https://github.com/actix/actix-extras/pull/213
## 0.6.0-beta.5 - 2021-12-12
* Update `actix-web` dependency to `4.0.0.beta-14`. [#209]

View File

@ -1,6 +1,6 @@
[package]
name = "actix-cors"
version = "0.6.0-beta.5"
version = "0.6.0-beta.6"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Rob Ede <robjtede@icloud.com>",

View File

@ -3,9 +3,9 @@
> Cross-origin resource sharing (CORS) for Actix Web.
[![crates.io](https://img.shields.io/crates/v/actix-cors?label=latest)](https://crates.io/crates/actix-cors)
[![Documentation](https://docs.rs/actix-cors/badge.svg?version=0.6.0-beta.5)](https://docs.rs/actix-cors/0.6.0-beta.5)
[![Documentation](https://docs.rs/actix-cors/badge.svg?version=0.6.0-beta.6)](https://docs.rs/actix-cors/0.6.0-beta.6)
![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-cors)
[![Dependency Status](https://deps.rs/crate/actix-cors/0.6.0-beta.5/status.svg)](https://deps.rs/crate/actix-cors/0.6.0-beta.5)
[![Dependency Status](https://deps.rs/crate/actix-cors/0.6.0-beta.6/status.svg)](https://deps.rs/crate/actix-cors/0.6.0-beta.6)
## Documentation & Resources

View File

@ -35,9 +35,13 @@ async fn main() -> std::io::Result<()> {
.allowed_header(header::CONTENT_TYPE)
// set list of headers that are safe to expose
.expose_headers(&[header::CONTENT_DISPOSITION])
// set CORS rules ttl
// set preflight cache TTL
.max_age(3600),
)
.route(
"/{n}/init",
web::to(|path: web::Path<String>| async move { path.into_inner() }),
)
.default_service(web::to(|| async { "Hello world!" }))
})
.bind("127.0.0.1:8080")?

View File

@ -163,10 +163,6 @@ where
}
}
let (req, pl) = req.into_parts();
let req2 = req.clone();
let req = ServiceRequest::from_parts(req, pl);
let inner = Rc::clone(&self.inner);
let fut = self.service.call(req);
@ -174,16 +170,7 @@ where
let res = fut.await;
if origin.is_some() {
let res = match res {
Ok(res) => res,
Err(err) => {
let res = HttpResponse::from_error(err);
let res = ServiceResponse::new(req2, res);
return Ok(res.map_into_right_body());
}
};
Ok(Self::augment_response(&inner, res))
Ok(Self::augment_response(&inner, res?))
} else {
res
}

View File

@ -28,5 +28,5 @@ futures-core = { version = "0.3.7", default-features = false }
pin-project-lite = "0.2.7"
[dev-dependencies]
actix-cors = "0.6.0-beta.5"
actix-cors = "0.6.0-beta.6"
actix-rt = "2"