diff --git a/examples/poem/local-server-with-browser/src/main.rs b/examples/poem/local-server-with-browser/src/main.rs index ae36067e24..85766021c2 100644 --- a/examples/poem/local-server-with-browser/src/main.rs +++ b/examples/poem/local-server-with-browser/src/main.rs @@ -19,7 +19,7 @@ async fn main() -> Result<(), std::io::Error> { // To test port assignment, run two instances of this example at once. // - // For ports <1024, running with administrator priveledges would be needed + // For ports <1024, running with administrator privileges would be needed // on Unix. For port 0, the OS would assign a port and we'd need to find out // what that port's number is. let (min_port, max_port) = (8080, 8085); diff --git a/poem-grpc-build/src/server.rs b/poem-grpc-build/src/server.rs index a8f1196548..fdeccd550c 100644 --- a/poem-grpc-build/src/server.rs +++ b/poem-grpc-build/src/server.rs @@ -101,7 +101,7 @@ pub(crate) fn generate(config: &GrpcConfig, service: &Service, buf: &mut String) #[allow(unused_imports)] pub struct #server_ident { inner: ::std::sync::Arc, - send_compressd: ::std::option::Option<#crate_name::CompressionEncoding>, + send_compressed: ::std::option::Option<#crate_name::CompressionEncoding>, accept_compressed: ::std::sync::Arc<[#crate_name::CompressionEncoding]>, } @@ -110,7 +110,7 @@ pub(crate) fn generate(config: &GrpcConfig, service: &Service, buf: &mut String) fn clone(&self) -> Self { Self { inner: self.inner.clone(), - send_compressd: self.send_compressd, + send_compressed: self.send_compressed, accept_compressed: self.accept_compressed.clone(), } } @@ -127,7 +127,7 @@ pub(crate) fn generate(config: &GrpcConfig, service: &Service, buf: &mut String) pub fn new(service: T) -> Self { Self { inner: ::std::sync::Arc::new(service), - send_compressd: ::std::option::Option::None, + send_compressed: ::std::option::Option::None, accept_compressed: ::std::sync::Arc::new([]), } } @@ -135,7 +135,7 @@ pub(crate) fn generate(config: &GrpcConfig, service: &Service, buf: &mut String) /// Set the compression encoding for sending pub fn send_compressed(self, encoding: #crate_name::CompressionEncoding) -> Self { Self { - send_compressd: Some(encoding), + send_compressed: Some(encoding), ..self } } @@ -226,7 +226,7 @@ fn generate_unary(codec_list: &[Path], method_info: MethodInfo) -> TokenStream { crate_name, codec_list, quote! { - #crate_name::server::GrpcServer::new(codec, server.send_compressd, &server.accept_compressed).unary(#proxy_service_ident(server.inner.clone()), req).await + #crate_name::server::GrpcServer::new(codec, server.send_compressed, &server.accept_compressed).unary(#proxy_service_ident(server.inner.clone()), req).await }, ); @@ -270,7 +270,7 @@ fn generate_client_streaming(codec_list: &[Path], method_info: MethodInfo) -> To crate_name, codec_list, quote! { - #crate_name::server::GrpcServer::new(codec, server.send_compressd, &server.accept_compressed).client_streaming(#proxy_service_ident(server.inner.clone()), req).await + #crate_name::server::GrpcServer::new(codec, server.send_compressed, &server.accept_compressed).client_streaming(#proxy_service_ident(server.inner.clone()), req).await }, ); @@ -314,7 +314,7 @@ fn generate_server_streaming(codec_list: &[Path], method_info: MethodInfo) -> To crate_name, codec_list, quote! { - #crate_name::server::GrpcServer::new(codec, server.send_compressd, &server.accept_compressed).server_streaming(#proxy_service_ident(server.inner.clone()), req).await + #crate_name::server::GrpcServer::new(codec, server.send_compressed, &server.accept_compressed).server_streaming(#proxy_service_ident(server.inner.clone()), req).await }, ); @@ -358,7 +358,7 @@ fn generate_bidirectional_streaming(codec_list: &[Path], method_info: MethodInfo crate_name, codec_list, quote! { - #crate_name::server::GrpcServer::new(codec, server.send_compressd, &server.accept_compressed).bidirectional_streaming(#proxy_service_ident(server.inner.clone()), req).await + #crate_name::server::GrpcServer::new(codec, server.send_compressed, &server.accept_compressed).bidirectional_streaming(#proxy_service_ident(server.inner.clone()), req).await }, ); diff --git a/poem-grpc/src/client.rs b/poem-grpc/src/client.rs index 560ac58068..7d8701f596 100644 --- a/poem-grpc/src/client.rs +++ b/poem-grpc/src/client.rs @@ -172,7 +172,7 @@ impl ClientConfigBuilder { #[derive(Clone)] pub struct GrpcClient { ep: Arc + 'static>, - send_compressd: Option, + send_compressed: Option, accept_compressed: Arc<[CompressionEncoding]>, } @@ -181,7 +181,7 @@ impl GrpcClient { pub fn new(config: ClientConfig) -> Self { Self { ep: create_client_endpoint(config), - send_compressd: None, + send_compressed: None, accept_compressed: Arc::new([]), } } @@ -194,13 +194,13 @@ impl GrpcClient { { Self { ep: Arc::new(ToDynEndpoint(ep.map_to_response())), - send_compressd: None, + send_compressed: None, accept_compressed: Arc::new([]), } } pub fn set_send_compressed(&mut self, encoding: CompressionEncoding) { - self.send_compressd = Some(encoding); + self.send_compressed = Some(encoding); } pub fn set_accept_compressed(&mut self, encodings: impl Into>) { @@ -230,11 +230,11 @@ impl GrpcClient { extensions, } = request; let mut http_request = - create_http_request::(path, metadata, extensions, self.send_compressd); + create_http_request::(path, metadata, extensions, self.send_compressed); http_request.set_body(create_encode_request_body( codec.encoder(), Streaming::new(futures_util::stream::once(async move { Ok(message) })), - self.send_compressd, + self.send_compressed, )); let mut resp = self @@ -279,11 +279,11 @@ impl GrpcClient { extensions, } = request; let mut http_request = - create_http_request::(path, metadata, extensions, self.send_compressd); + create_http_request::(path, metadata, extensions, self.send_compressed); http_request.set_body(create_encode_request_body( codec.encoder(), message, - self.send_compressd, + self.send_compressed, )); let mut resp = self @@ -328,11 +328,11 @@ impl GrpcClient { extensions, } = request; let mut http_request = - create_http_request::(path, metadata, extensions, self.send_compressd); + create_http_request::(path, metadata, extensions, self.send_compressed); http_request.set_body(create_encode_request_body( codec.encoder(), Streaming::new(futures_util::stream::once(async move { Ok(message) })), - self.send_compressd, + self.send_compressed, )); let mut resp = self @@ -373,11 +373,11 @@ impl GrpcClient { extensions, } = request; let mut http_request = - create_http_request::(path, metadata, extensions, self.send_compressd); + create_http_request::(path, metadata, extensions, self.send_compressed); http_request.set_body(create_encode_request_body( codec.encoder(), message, - self.send_compressd, + self.send_compressed, )); let mut resp = self @@ -411,7 +411,7 @@ fn create_http_request( path: &str, metadata: Metadata, extensions: Extensions, - send_compressd: Option, + send_compressed: Option, ) -> HttpRequest { let mut http_request = HttpRequest::builder() .uri_str(path) @@ -426,10 +426,10 @@ fn create_http_request( http_request .headers_mut() .insert(header::TE, "trailers".parse().unwrap()); - if let Some(send_compressd) = send_compressd { + if let Some(send_compressed) = send_compressed { http_request.headers_mut().insert( "grpc-encoding", - HeaderValue::from_str(send_compressd.as_str()).expect("BUG: invalid encoding"), + HeaderValue::from_str(send_compressed.as_str()).expect("BUG: invalid encoding"), ); } http_request diff --git a/poem-grpc/src/metadata.rs b/poem-grpc/src/metadata.rs index 54e34a6a8b..9ecb68f333 100644 --- a/poem-grpc/src/metadata.rs +++ b/poem-grpc/src/metadata.rs @@ -1,4 +1,4 @@ -//! Metadata releated types +//! Metadata related types use std::str::FromStr; diff --git a/poem-grpc/src/server.rs b/poem-grpc/src/server.rs index 3e1b14de43..8dcf0a0f25 100644 --- a/poem-grpc/src/server.rs +++ b/poem-grpc/src/server.rs @@ -16,7 +16,7 @@ use crate::{ #[doc(hidden)] pub struct GrpcServer<'a, T> { codec: T, - send_compressd: Option, + send_compressed: Option, accept_compressed: &'a [CompressionEncoding], } @@ -24,12 +24,12 @@ impl<'a, T: Codec> GrpcServer<'a, T> { #[inline] pub fn new( codec: T, - send_compressd: Option, + send_compressed: Option, accept_compressed: &'a [CompressionEncoding], ) -> Self { Self { codec, - send_compressd, + send_compressed, accept_compressed, } } @@ -72,9 +72,9 @@ impl<'a, T: Codec> GrpcServer<'a, T> { let body = create_encode_response_body( self.codec.encoder(), Streaming::new(futures_util::stream::once(async move { Ok(message) })), - self.send_compressd, + self.send_compressed, ); - update_http_response(&mut resp, metadata, body, self.send_compressd); + update_http_response(&mut resp, metadata, body, self.send_compressed); } Err(status) => resp.headers_mut().extend(status.to_headers()), } @@ -114,9 +114,9 @@ impl<'a, T: Codec> GrpcServer<'a, T> { let body = create_encode_response_body( self.codec.encoder(), Streaming::new(futures_util::stream::once(async move { Ok(message) })), - self.send_compressd, + self.send_compressed, ); - update_http_response(&mut resp, metadata, body, self.send_compressd); + update_http_response(&mut resp, metadata, body, self.send_compressed); } Err(status) => { resp.headers_mut().extend(status.to_headers()); @@ -161,9 +161,12 @@ impl<'a, T: Codec> GrpcServer<'a, T> { match res { Ok(grpc_resp) => { let GrpcResponse { metadata, message } = grpc_resp; - let body = - create_encode_response_body(self.codec.encoder(), message, self.send_compressd); - update_http_response(&mut resp, metadata, body, self.send_compressd); + let body = create_encode_response_body( + self.codec.encoder(), + message, + self.send_compressed, + ); + update_http_response(&mut resp, metadata, body, self.send_compressed); } Err(status) => { resp.headers_mut().extend(status.to_headers()); @@ -202,9 +205,12 @@ impl<'a, T: Codec> GrpcServer<'a, T> { match res { Ok(grpc_resp) => { let GrpcResponse { metadata, message } = grpc_resp; - let body = - create_encode_response_body(self.codec.encoder(), message, self.send_compressd); - update_http_response(&mut resp, metadata, body, self.send_compressd); + let body = create_encode_response_body( + self.codec.encoder(), + message, + self.send_compressed, + ); + update_http_response(&mut resp, metadata, body, self.send_compressed); } Err(status) => { resp.headers_mut().extend(status.to_headers()); @@ -219,13 +225,13 @@ fn update_http_response( resp: &mut Response, metadata: Metadata, body: Body, - send_compressd: Option, + send_compressed: Option, ) { resp.headers_mut().extend(metadata.headers); - if let Some(send_compressd) = send_compressd { + if let Some(send_compressed) = send_compressed { resp.headers_mut().insert( "grpc-encoding", - HeaderValue::from_str(send_compressd.as_str()).expect("BUG: invalid encoding"), + HeaderValue::from_str(send_compressed.as_str()).expect("BUG: invalid encoding"), ); } resp.set_body(body); diff --git a/poem-openapi/CHANGELOG.md b/poem-openapi/CHANGELOG.md index a4df99f10e..875268aaa8 100644 --- a/poem-openapi/CHANGELOG.md +++ b/poem-openapi/CHANGELOG.md @@ -49,7 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # [4.0.0] 2024-01-06 - upgrade to `hyper1` -- added documetation on how to merge API specs [#716](https://github.com/poem-web/poem/pull/716) +- added documentation on how to merge API specs [#716](https://github.com/poem-web/poem/pull/716) - impl Type for std::time::Duration instead of only humantime::Duration [#713](https://github.com/poem-web/poem/pull/713) # [3.0.6] 2023-11-19 @@ -96,7 +96,7 @@ struct Obj { # [3.0.1] 2023-08-02 -- openapi: allows multiple secutity schemes on one operation [#621](https://github.com/poem-web/poem/issues/621) +- openapi: allows multiple security schemes on one operation [#621](https://github.com/poem-web/poem/issues/621) # [3.0.0] 2023-06-21 @@ -420,7 +420,7 @@ struct Obj { # [1.2.11] 2021-12-27 -- Remove the `OpenApi::combine` method, `OpenApiSerice::new` can be passed a tuple to combine multiple API objects. +- Remove the `OpenApi::combine` method, `OpenApiService::new` can be passed a tuple to combine multiple API objects. # [1.2.10] 2021-12-26 diff --git a/poem/CHANGELOG.md b/poem/CHANGELOG.md index 093de6a688..e03cb7a4ae 100644 --- a/poem/CHANGELOG.md +++ b/poem/CHANGELOG.md @@ -11,11 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # [3.1.3] 2024-10-21 -- Add `Middlware::combine_if` method. +- Add `Middleware::combine_if` method. # [3.1.2] 2024-10-21 -- Add `Middlware::combine` method to combine two middlewares. +- Add `Middleware::combine` method to combine two middlewares. # [3.1.1] 2024-10-02 diff --git a/poem/src/middleware/mod.rs b/poem/src/middleware/mod.rs index 5102b67389..0fe8d26a22 100644 --- a/poem/src/middleware/mod.rs +++ b/poem/src/middleware/mod.rs @@ -326,9 +326,9 @@ where /// purpose sum type with two cases. pub enum EitherMiddleware { - /// A middlware of type `A` + /// A middleware of type `A` A(A, PhantomData), - /// B middlware of type `B` + /// B middleware of type `B` B(B, PhantomData), }