-
Notifications
You must be signed in to change notification settings - Fork 11
Handle additionalInput without modifying the actual input model #787
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
Open
adwsingh
wants to merge
1
commit into
main
Choose a base branch
from
adwsingh/fix-additional-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+232
−74
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...er/server-proxy/src/main/java/software/amazon/smithy/java/server/ProxyOperationTrait.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.java.server; | ||
|
||
import software.amazon.smithy.model.node.Node; | ||
import software.amazon.smithy.model.shapes.ShapeId; | ||
import software.amazon.smithy.model.traits.Trait; | ||
|
||
/** | ||
* A trait that marks operations as proxies to delegate operations. | ||
* | ||
* <p>Operations annotated with this trait are treated as proxies to the | ||
* delegate operation specified by this trait. Proxy operations enable | ||
* additional input processing while maintaining compatibility with the | ||
* original operation interface.</p> | ||
* | ||
* <h3>Proxy Operation Input Handling</h3> | ||
* <p>Proxy operation inputs are expected to be a superset of the original | ||
* operation input. For operations with existing input, a new input structure | ||
* is created that contains all original input members plus an | ||
* {@code additionalInput} field containing the additional parameters. For | ||
* operations with no input, the additional input structure is used directly.</p> | ||
* | ||
* <h3>Additional Input Access</h3> | ||
* <p>The additional input data can be accessed in Dynamic client interceptors | ||
* using the {@code ProxyService.PROXY_INPUT} context key. This enables | ||
* interceptors to process the extra data before the request is forwarded | ||
* to the delegate service.</p> | ||
* | ||
* <h3>Input Stripping</h3> | ||
* <p>The proxy service automatically strips out the additional input before | ||
* sending the request to the delegate service, ensuring that only the | ||
* expected input parameters are forwarded to the original operation.</p> | ||
* | ||
* @see ProxyService#PROXY_INPUT | ||
*/ | ||
public class ProxyOperationTrait implements Trait { | ||
|
||
private static final ShapeId SHAPE_ID = ShapeId.from("smithy.server.api#proxyOperation"); | ||
private final ShapeId delegateOperation; | ||
|
||
public ProxyOperationTrait(ShapeId delegateOperation) { | ||
this.delegateOperation = delegateOperation; | ||
} | ||
|
||
@Override | ||
public ShapeId toShapeId() { | ||
return SHAPE_ID; | ||
} | ||
|
||
@Override | ||
public Node toNode() { | ||
return null; | ||
} | ||
|
||
public ShapeId getDelegateOperation() { | ||
return delegateOperation; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.