Skip to content

Commit f6bec88

Browse files
poem 3.0.0
Co-Authored-By: hzlinyiyu <[email protected]>
1 parent cba2ecb commit f6bec88

File tree

22 files changed

+63
-77
lines changed

22 files changed

+63
-77
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ repository = "https://github.com/poem-web/poem"
2020
rust-version = "1.75"
2121

2222
[workspace.dependencies]
23-
poem = { path = "poem", version = "2.0.1", default-features = false }
24-
poem-derive = { path = "poem-derive", version = "2.0.1" }
25-
poem-openapi-derive = { path = "poem-openapi-derive", version = "4.0.1" }
26-
poem-grpc-build = { path = "poem-grpc-build", version = "0.3.0" }
23+
poem = { path = "poem", version = "3.0.0", default-features = false }
24+
poem-derive = { path = "poem-derive", version = "3.0.0" }
25+
poem-openapi-derive = { path = "poem-openapi-derive", version = "5.0.0" }
26+
poem-grpc-build = { path = "poem-grpc-build", version = "0.4.0" }
2727

2828
proc-macro-crate = "3.0.0"
2929
proc-macro2 = "1.0.29"
@@ -42,7 +42,7 @@ futures-util = "0.3.17"
4242
tokio-stream = "0.1.8"
4343
serde_yaml = "0.9"
4444
quick-xml = { version = "0.31.0", features = ["serialize"] }
45-
base64 = "0.21.0"
45+
base64 = "0.22.0"
4646
serde_urlencoded = "0.7.1"
4747
indexmap = "2.0.0"
4848
reqwest = { version = "0.12.2", default-features = false }

poem-derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poem-derive"
3-
version = "2.0.1"
3+
version = "3.0.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

poem-grpc-build/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poem-grpc-build"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

poem-grpc/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poem-grpc"
3-
version = "0.3.0"
3+
version = "0.4.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true
@@ -28,7 +28,7 @@ itoa = "1.0.2"
2828
percent-encoding = "2.1.0"
2929
bytes.workspace = true
3030
prost = "0.12.0"
31-
base64 = "0.21.0"
31+
base64.workspace = true
3232
prost-types = "0.12.0"
3333
tokio-stream = { workspace = true, features = ["sync"] }
3434
serde = { workspace = true, optional = true }

poem-grpc/src/reflection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl Reflection {
138138
let fd_iter = std::mem::take(&mut this.file_descriptor_sets)
139139
.into_iter()
140140
.flat_map(|fds| fds.file.into_iter());
141-
let mut files = HashMap::new();
141+
let mut files = HashMap::with_capacity(fd_iter.size_hint().0);
142142

143143
for fd in fd_iter {
144144
let fd = Arc::new(fd);

poem-lambda/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
# [5.0.0] 2024-03-24
7+
# [5.0.0] 2024-03-30
88

99
- use AFIT instead of `async_trait`
1010
- Bump `lambda_http` from `0.9` to `0.10`

poem-lambda/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poem-lambda"
3-
version = "4.0.0"
3+
version = "5.0.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true
@@ -21,7 +21,7 @@ categories = [
2121
[dependencies]
2222
poem = { workspace = true, default-features = false }
2323

24-
lambda_http = { version = "0.10.0" }
24+
lambda_http = { version = "0.11.0" }
2525

2626
[dev-dependencies]
2727
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

poem-openapi-derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poem-openapi-derive"
3-
version = "4.0.1"
3+
version = "5.0.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

poem-openapi/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
# [5.0.0] 2024-03-24
7+
# [5.0.0] 2024-03-30
88

99
- use AFIT instead of `async_trait`
1010
- add `Upload::size` method

poem-openapi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poem-openapi"
3-
version = "4.0.1"
3+
version = "5.0.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

poem-openapi/src/openapi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl<T: OpenApi, W: Webhook> IntoEndpoint for OpenApiService<T, W> {
651651
#[cfg(test)]
652652
mod tests {
653653
use super::*;
654-
use crate::{types::Type, OpenApi};
654+
use crate::OpenApi;
655655

656656
#[test]
657657
fn extra_response_headers() {

poem/CHANGELOG.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
# [3.0.0] 2024-03-24
7+
# [3.0.0] 2024-03-30
88

99
- use AFIT instead of `async_trait`
10-
- bump `priority-queue` to 2.0
11-
- bump `x509-parser` to 0.16
12-
- bump `nix` to 0.28
13-
- bump `redis` to 0.25
14-
- bump `reqwest` to 0.12
15-
- bump `opentelemetry` to 0.22 [#784](https://github.com/poem-web/poem/pull/784)
10+
- bump `priority-queue` to `2.0`
11+
- bump `x509-parser` to `0.16`
12+
- bump `nix` to `0.28`
13+
- bump `redis` to `0.25`
14+
- bump `reqwest` to `0.12`
15+
- bump `opentelemetry` to `0.22` [#784](https://github.com/poem-web/poem/pull/784)
16+
- bump `sync_wrapper` to `1.0.0`
17+
- bump `rcgen ` to `0.13.0`
18+
- bump `base64 ` to `0.22.0`
1619

1720
# [2.0.1] 2024-03-04
1821

poem/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "poem"
3-
version = "2.0.1"
3+
version = "3.0.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true
@@ -92,7 +92,7 @@ thiserror.workspace = true
9292
rfc7239 = "0.1.0"
9393
mime.workspace = true
9494
wildmatch = "2"
95-
sync_wrapper = { version = "0.1.2", features = ["futures"] }
95+
sync_wrapper = { version = "1.0.0", features = ["futures"] }
9696

9797
# Non-feature optional dependencies
9898
multer = { version = "3.0.0", features = ["tokio"], optional = true }
@@ -150,7 +150,7 @@ unic-langid = { version = "0.9.0", optional = true, features = ["macros"] }
150150
intl-memoizer = { version = "0.5.1", optional = true }
151151
ring = { version = "0.17.7", optional = true }
152152
reqwest = { workspace = true, features = ["json"], optional = true }
153-
rcgen = { version = "0.12.0", optional = true }
153+
rcgen = { version = "0.13.0", optional = true }
154154
x509-parser = { version = "0.16.0", optional = true }
155155
tokio-metrics = { version = "0.3.0", optional = true }
156156
rust-embed = { version = "8.0", optional = true }

poem/src/listener/acme/listener.rs

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ use std::{
55
};
66

77
use http::uri::Scheme;
8-
use rcgen::{
9-
Certificate, CertificateParams, CustomExtension, DistinguishedName, PKCS_ECDSA_P256_SHA256,
10-
};
8+
use rcgen::{CertificateParams, CustomExtension, KeyPair, PKCS_ECDSA_P256_SHA256};
119
use tokio_rustls::{
1210
rustls::{
1311
crypto::ring::sign::any_ecdsa_type,
@@ -229,21 +227,21 @@ impl<T: Acceptor> Acceptor for AutoCertAcceptor<T> {
229227
}
230228

231229
fn gen_acme_cert(domain: &str, acme_hash: &[u8]) -> IoResult<CertifiedKey> {
232-
let mut params = CertificateParams::new(vec![domain.to_string()]);
233-
params.alg = &PKCS_ECDSA_P256_SHA256;
234-
params.custom_extensions = vec![CustomExtension::new_acme_identifier(acme_hash)];
235-
let cert = Certificate::from_params(params)
236-
.map_err(|_| IoError::new(ErrorKind::Other, "failed to generate acme certificate"))?;
237-
let key = any_ecdsa_type(&PrivateKeyDer::Pkcs8(
238-
cert.serialize_private_key_der().into(),
239-
))
240-
.unwrap();
241-
Ok(CertifiedKey::new(
242-
vec![CertificateDer::from(cert.serialize_der().map_err(
243-
|_| IoError::new(ErrorKind::Other, "failed to serialize acme certificate"),
244-
)?)],
245-
key,
246-
))
230+
let keypair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256).expect("create key pair");
231+
let cert = CertificateParams::new(vec![domain.to_string()])
232+
.and_then(|mut params| {
233+
params.custom_extensions = vec![CustomExtension::new_acme_identifier(acme_hash)];
234+
params.self_signed(&keypair)
235+
})
236+
.map_err(|err| {
237+
IoError::new(
238+
ErrorKind::Other,
239+
format!("failed to generate acme certificate: {err}"),
240+
)
241+
})?;
242+
243+
let key = any_ecdsa_type(&PrivateKeyDer::Pkcs8(keypair.serialized_der().into())).unwrap();
244+
Ok(CertifiedKey::new(vec![cert.der().clone()], key))
247245
}
248246

249247
/// The result of [`issue_cert`] function.
@@ -343,31 +341,23 @@ pub async fn issue_cert<T: AsRef<str>>(
343341
}
344342

345343
// send csr
346-
let mut params = CertificateParams::new(
344+
let keypair = KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256).expect("create key pair");
345+
let request = CertificateParams::new(
347346
domains
348347
.iter()
349348
.map(|domain| domain.as_ref().to_string())
350349
.collect::<Vec<_>>(),
351-
);
352-
params.distinguished_name = DistinguishedName::new();
353-
params.alg = &PKCS_ECDSA_P256_SHA256;
354-
let cert = Certificate::from_params(params).map_err(|err| {
350+
)
351+
.and_then(|params| params.serialize_request(&keypair))
352+
.map_err(|err| {
355353
IoError::new(
356354
ErrorKind::Other,
357355
format!("failed create certificate request: {err}"),
358356
)
359357
})?;
360-
let pk = any_ecdsa_type(&PrivateKeyDer::Pkcs8(
361-
cert.serialize_private_key_der().into(),
362-
))
363-
.unwrap();
364-
let csr = cert.serialize_request_der().map_err(|err| {
365-
IoError::new(
366-
ErrorKind::Other,
367-
format!("failed to serialize request der {err}"),
368-
)
369-
})?;
370358

359+
let pk = any_ecdsa_type(&PrivateKeyDer::Pkcs8(keypair.serialized_der().into())).unwrap();
360+
let csr = request.der().as_ref();
371361
let order_resp = client.send_csr(&order_resp.finalize, &csr).await?;
372362

373363
if order_resp.status == "invalid" {
@@ -403,7 +393,7 @@ pub async fn issue_cert<T: AsRef<str>>(
403393
)
404394
})?)
405395
.await?;
406-
let pkey_pem = cert.serialize_private_key_pem();
396+
let pkey_pem = keypair.serialize_pem();
407397
let cert_chain = rustls_pemfile::certs(&mut acme_cert_pem.as_slice())
408398
.collect::<Result<_, _>>()
409399
.map_err(|err| IoError::new(ErrorKind::Other, format!("invalid pem: {err}")))?;

poem/src/listener/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,7 @@ impl Listener for BoxListener {
387387

388388
#[cfg(test)]
389389
mod tests {
390-
use super::{AcceptorExt, *};
391-
use crate::listener::TcpListener;
390+
use super::*;
392391

393392
#[tokio::test]
394393
async fn combined_listener() {

poem/src/listener/rustls.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ impl RustlsConfig {
222222
.map(|fallback| fallback.create_certificate_key())
223223
.transpose()?
224224
.map(Arc::new);
225-
let mut certifcate_keys = HashMap::new();
225+
let mut certificate_keys = HashMap::with_capacity(self.certificates.len());
226226

227227
for (name, certificate) in &self.certificates {
228-
certifcate_keys.insert(
228+
certificate_keys.insert(
229229
name.clone(),
230230
Arc::new(certificate.create_certificate_key()?),
231231
);
@@ -252,7 +252,7 @@ impl RustlsConfig {
252252
};
253253

254254
let mut server_config = builder.with_cert_resolver(Arc::new(ResolveServerCert {
255-
certifcate_keys,
255+
certificate_keys,
256256
fallback,
257257
}));
258258
server_config.alpn_protocols = vec!["h2".into(), "http/1.1".into()];
@@ -401,15 +401,15 @@ where
401401

402402
#[derive(Debug)]
403403
struct ResolveServerCert {
404-
certifcate_keys: HashMap<String, Arc<CertifiedKey>>,
404+
certificate_keys: HashMap<String, Arc<CertifiedKey>>,
405405
fallback: Option<Arc<CertifiedKey>>,
406406
}
407407

408408
impl ResolvesServerCert for ResolveServerCert {
409409
fn resolve(&self, client_hello: ClientHello) -> Option<Arc<CertifiedKey>> {
410410
client_hello
411411
.server_name()
412-
.and_then(|name| self.certifcate_keys.get(name).cloned())
412+
.and_then(|name| self.certificate_keys.get(name).cloned())
413413
.or_else(|| self.fallback.clone())
414414
}
415415
}

poem/src/middleware/cookie_jar_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<E: Endpoint> Endpoint for CookieJarManagerEndpoint<E> {
5555
async fn call(&self, mut req: Request) -> Result<Self::Output> {
5656
if req.state().cookie_jar.is_none() {
5757
let mut cookie_jar = CookieJar::extract_from_headers(req.headers());
58-
cookie_jar.key = self.key.clone();
58+
cookie_jar.key.clone_from(&self.key);
5959
req.state_mut().cookie_jar = Some(cookie_jar.clone());
6060
let mut resp = self.inner.call(req).await?.into_response();
6161
cookie_jar.append_delta_to_headers(resp.headers_mut());

poem/src/route/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fn normalize_path(path: &str) -> String {
387387
#[cfg(test)]
388388
mod tests {
389389
use futures_util::lock::Mutex;
390-
use http::{StatusCode, Uri};
390+
use http::StatusCode;
391391

392392
use super::*;
393393
use crate::{endpoint::make_sync, handler, test::TestClient, Error};

poem/src/route/router_method.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,7 @@ where
281281
#[cfg(test)]
282282
mod tests {
283283
use super::*;
284-
use crate::{
285-
handler,
286-
http::{Method, StatusCode},
287-
test::TestClient,
288-
};
284+
use crate::{handler, http::StatusCode, test::TestClient};
289285

290286
#[tokio::test]
291287
async fn method_not_allowed() {

poem/src/web/accept.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ impl<'a> FromRequest<'a> for Accept {
3636
mod tests {
3737
use std::str::FromStr;
3838

39-
use http::header;
40-
4139
use super::*;
4240

4341
#[tokio::test]

0 commit comments

Comments
 (0)