-
Notifications
You must be signed in to change notification settings - Fork 427
Add a new field, transportSpecific to ServerContext #2228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
/// | ||
/// An example of what this field can be used for, would be to store | ||
/// things like a peerCertificate from a mTLS connection | ||
public var transportSpecific: (any Sendable)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this some more, rather than any Sendable
can you define a public protocol TransportSpecific: Sendable {}
nested within ServerContext
and use that instead?
It has a few advantages:
- Compiler helps users out a little more
- It's easier to document and easier for users to find implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @jtdavey!
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