Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/better-grpc-split' into …
Browse files Browse the repository at this point in the history
…feature/better-grpc-split

# Conflicts:
#	tests/code-generation-workspace-split-grpc/.gitignore
#	tests/code-generation-workspace-split-grpc/Cargo.toml
#	tests/code-generation-workspace-split-grpc/volo.workspace.yml
  • Loading branch information
missingdays committed Dec 3, 2024
2 parents 5ff5619 + 3c3f7db commit dd382aa
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/code-generation-workspace-split-grpc/proto/echo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

package echo;

message EchoRequest {
string message = 1;
}

message EchoResponse {
string message = 1;
}

service Echo {
rpc Echo(EchoRequest) returns (EchoResponse) {}
}
2 changes: 1 addition & 1 deletion volo-http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "volo-http"
version = "0.3.0"
version = "0.3.1"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down
12 changes: 5 additions & 7 deletions volo-http/src/server/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,11 @@ impl FromContext for ClientIp {
type Rejection = Infallible;

async fn from_context(cx: &mut ServerContext, _: &mut Parts) -> Result<Self, Self::Rejection> {
Ok(ClientIp(
cx.rpc_info
.caller()
.tags
.get::<ClientIp>()
.and_then(|v| v.0),
))
if let Some(client_ip) = cx.extensions().get::<ClientIp>() {
Ok(client_ip.to_owned())
} else {
Ok(ClientIp(None))
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion volo-http/src/server/utils/client_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ where
req: Request<B>,
) -> Result<Self::Response, Self::Error> {
let client_ip = self.get_client_ip(cx, req.headers());
cx.rpc_info_mut().caller_mut().insert(client_ip);
cx.extensions_mut().insert(client_ip);

self.service.call(cx, req).await
}
Expand Down

0 comments on commit dd382aa

Please sign in to comment.