Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Sep 12, 2024
2 parents b442ae6 + a584e51 commit 5fc45f2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions poem-grpc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [0.5.1] 2024-09-12

- set the correct `content-type` for `GrpcClient`

# [0.5.0] 2024-09-08

- add support for GRPC compression
Expand Down
2 changes: 1 addition & 1 deletion poem-grpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "poem-grpc"
version = "0.5.0"
version = "0.5.1"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
10 changes: 7 additions & 3 deletions poem-grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,15 @@ fn create_http_request<T: Codec>(
.uri_str(path)
.method(Method::POST)
.version(Version::HTTP_2)
.content_type(T::CONTENT_TYPES[0])
.header(header::TE, "trailers")
.finish();
http_request.headers_mut().extend(metadata.headers);
*http_request.headers_mut() = metadata.headers;
*http_request.extensions_mut() = extensions;
http_request
.headers_mut()
.insert("content-type", T::CONTENT_TYPES[0].parse().unwrap());
http_request
.headers_mut()
.insert(header::TE, "trailers".parse().unwrap());
if let Some(send_compressd) = send_compressd {
http_request.headers_mut().insert(
"grpc-encoding",
Expand Down
4 changes: 4 additions & 0 deletions poem-openapi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# Unreleased

- implements `Serialize` and `Deserialize` for `poem_openapi::types::Any<T>`.

# [5.1.0] 2024-09-08

- fix read_only_with_default test when only default features are enabled [#854](https://github.com/poem-web/poem/pulls)
Expand Down
22 changes: 21 additions & 1 deletion poem-openapi/src/types/any.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;

use serde::{de::DeserializeOwned, Serialize};
use serde::{de::DeserializeOwned, Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;

use crate::{
Expand Down Expand Up @@ -66,6 +66,26 @@ impl<T: Serialize + Send + Sync> ToXML for Any<T> {
}
}

impl<T: Serialize> Serialize for Any<T> {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.0.serialize(serializer)
}
}

impl<'de, T: DeserializeOwned> Deserialize<'de> for Any<T> {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
T::deserialize(deserializer).map(Self)
}
}

impl Type for Value {
const IS_REQUIRED: bool = true;

Expand Down

0 comments on commit 5fc45f2

Please sign in to comment.