-
Notifications
You must be signed in to change notification settings - Fork 46
Add RequestContext method to read attachments #2771
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
base: develop
Are you sure you want to change the base?
Conversation
Generate changelog in
|
✅ Successfully generated changelog entry!Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. 📋Changelog Preview✨ Features
|
| /** | ||
| * Returns the attachment associated with the given {@code key}. | ||
| * An {@link Optional#empty()} is returned if no such attachment exists. | ||
| */ | ||
| <T> Optional<T> attachment(AttachmentKey<T> key); |
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'm not sure this is appropriate for RequestContext.
RequestContext is designed to be a read-only interface for getting requests data not supported by the tool used to generate the endpoint implementations (either conjure or conjure-undertow-annotations). From the Javadoc for this interface:
Interface providing a view over data provided by the the original HTTP request including request headers and query parameters.
This method is meaningfully different. It's not exposing information about the request - it's exposing information from the underlying HttpServerExchange for this request.
| * Returns the attachment associated with the given {@code key}. | ||
| * An {@link Optional#empty()} is returned if no such attachment exists. | ||
| */ | ||
| <T> Optional<T> attachment(AttachmentKey<T> key); |
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.
This enables retrieving current request size from Witchcraft's
BytesReadHandlerin application code.
I'm also not convinced that we want to make this part of the public API of Witchcraft. This increases the surface area of the Witchcraft API and removes a degree of freedom for evolving our implementation in the future if necessary.
Before this PR
Adds an
attachment()method toRequestContextto readHttpServerExchangeattachments. This enables retrieving current request size from Witchcraft'sBytesReadHandlerin application code.RequestContextis internal-only per its javadoc, so adding methods should be safe.After this PR
==COMMIT_MSG==
Add
RequestContextmethod to read attachments.==COMMIT_MSG==