Skip to content

Commit a73320a

Browse files
committed
Add a new field, transportSpecific to ServerContext
Motivation: Currently there's no way to plumb through details from the transport level to a request handler. Adding this field allows transports, such as the nio transport, to add the peer certificate to the server context when using mTLS. From there there it's easy for an interceptor to take this data and propogate it forward to a request handler. Modifications: This PR adds a single field to the ServerContext that transports can use Result: A new field will be accessible to transports and consumers of the API
1 parent c295efd commit a73320a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/GRPCCore/Call/Server/ServerContext.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ public struct ServerContext: Sendable {
4545
/// - "in-process:27182".
4646
public var localPeer: String
4747

48+
/// An optional field for transports to store specific data
49+
///
50+
/// Refer to the transport documentation to understand what type of
51+
/// value this field will contain, if any.
52+
///
53+
/// An example of what this field can be used for, would be to store
54+
/// things like a peerCertificate from a mTLS connection
55+
public var transportSpecific: (any Sendable)?
56+
4857
/// A handle for checking the cancellation status of an RPC.
4958
public var cancellation: RPCCancellationHandle
5059

0 commit comments

Comments
 (0)