-
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?
Changes from all commits
bfa2be9
6456872
0707055
c0837e8
65e053a
dc4dcc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| acceptedBreaks: | ||
| "8.68.0": | ||
| com.palantir.conjure.java:conjure-undertow-lib: | ||
| - code: "java.method.addedToInterface" | ||
| new: "method <T> java.util.Optional<T> com.palantir.conjure.java.undertow.lib.RequestContext::attachment(io.undertow.util.AttachmentKey<T>)" | ||
| justification: "Add attachment() method to RequestContext, following the pattern of cookie(). RequestContext is only implemented by conjure-java-undertow-runtime." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import com.google.common.collect.ListMultimap; | ||
| import com.palantir.logsafe.Arg; | ||
| import com.palantir.logsafe.Unsafe; | ||
| import io.undertow.util.AttachmentKey; | ||
| import java.security.cert.Certificate; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
@@ -50,6 +51,12 @@ public interface RequestContext { | |
| */ | ||
| Optional<String> firstHeader(String headerName); | ||
|
|
||
| /** | ||
| * 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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. |
||
|
|
||
| /** | ||
| * Returns the value of the cookie named {@code cookieName}. | ||
| * An {@link Optional#empty()} is returned if no such cookie exists. | ||
|
|
||
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.RequestContextis 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:This method is meaningfully different. It's not exposing information about the request - it's exposing information from the underlying
HttpServerExchangefor this request.