Add RequestContext method to read attachments#2771
Add RequestContext method to read attachments#2771daanjanschouten wants to merge 6 commits intodevelopfrom
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.
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.
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==