mirror of
https://github.com/actix/actix-extras.git
synced 2025-02-20 01:34:22 +01:00
stop cloning request across service call (#213)
This commit is contained in:
parent
a0c93c62b3
commit
0805f2b1c6
@ -3,6 +3,12 @@
|
|||||||
## Unreleased - 2021-xx-xx
|
## 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
|
## 0.6.0-beta.5 - 2021-12-12
|
||||||
* Update `actix-web` dependency to `4.0.0.beta-14`. [#209]
|
* Update `actix-web` dependency to `4.0.0.beta-14`. [#209]
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-cors"
|
name = "actix-cors"
|
||||||
version = "0.6.0-beta.5"
|
version = "0.6.0-beta.6"
|
||||||
authors = [
|
authors = [
|
||||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||||
"Rob Ede <robjtede@icloud.com>",
|
"Rob Ede <robjtede@icloud.com>",
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
> Cross-origin resource sharing (CORS) for Actix Web.
|
> Cross-origin resource sharing (CORS) for Actix Web.
|
||||||
|
|
||||||
[](https://crates.io/crates/actix-cors)
|
[](https://crates.io/crates/actix-cors)
|
||||||
[](https://docs.rs/actix-cors/0.6.0-beta.5)
|
[](https://docs.rs/actix-cors/0.6.0-beta.6)
|
||||||

|

|
||||||
[](https://deps.rs/crate/actix-cors/0.6.0-beta.5)
|
[](https://deps.rs/crate/actix-cors/0.6.0-beta.6)
|
||||||
|
|
||||||
## Documentation & Resources
|
## Documentation & Resources
|
||||||
|
|
||||||
|
@ -35,9 +35,13 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.allowed_header(header::CONTENT_TYPE)
|
.allowed_header(header::CONTENT_TYPE)
|
||||||
// set list of headers that are safe to expose
|
// set list of headers that are safe to expose
|
||||||
.expose_headers(&[header::CONTENT_DISPOSITION])
|
.expose_headers(&[header::CONTENT_DISPOSITION])
|
||||||
// set CORS rules ttl
|
// set preflight cache TTL
|
||||||
.max_age(3600),
|
.max_age(3600),
|
||||||
)
|
)
|
||||||
|
.route(
|
||||||
|
"/{n}/init",
|
||||||
|
web::to(|path: web::Path<String>| async move { path.into_inner() }),
|
||||||
|
)
|
||||||
.default_service(web::to(|| async { "Hello world!" }))
|
.default_service(web::to(|| async { "Hello world!" }))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8080")?
|
.bind("127.0.0.1:8080")?
|
||||||
|
@ -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 inner = Rc::clone(&self.inner);
|
||||||
let fut = self.service.call(req);
|
let fut = self.service.call(req);
|
||||||
|
|
||||||
@ -174,16 +170,7 @@ where
|
|||||||
let res = fut.await;
|
let res = fut.await;
|
||||||
|
|
||||||
if origin.is_some() {
|
if origin.is_some() {
|
||||||
let res = match res {
|
Ok(Self::augment_response(&inner, 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))
|
|
||||||
} else {
|
} else {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,5 @@ futures-core = { version = "0.3.7", default-features = false }
|
|||||||
pin-project-lite = "0.2.7"
|
pin-project-lite = "0.2.7"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-cors = "0.6.0-beta.5"
|
actix-cors = "0.6.0-beta.6"
|
||||||
actix-rt = "2"
|
actix-rt = "2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user