-
Notifications
You must be signed in to change notification settings - Fork 154
Chain: Migrate Example to YAML - Fix for component names #2529
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b04383d
extend: enhance chain functionality, add reusable chain and CORS supp…
predic8 97d3326
enhance: add roadmap entry for configuration-independent bean lookup,…
predic8 c149985
refactor: add @NotNull annotations, improve Javadoc, and enhance comm…
predic8 ffe78e8
Merge branch 'master' into chain-example-yaml
predic8 80e3210
Merge branch 'master' into chain-example-yaml
rrayst 2386e09
refactor: MethodSetter logic now handles MCOtherAttributes-only eleme…
rrayst fb1c055
Merge remote-tracking branch 'origin/chain-example-yaml' into chain-e…
rrayst 12a173e
fix: compiler error
rrayst a0c88f3
refactor
rrayst 21f9215
refactor
rrayst 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
Some comments aren't visible on the classic Files Changed page.
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
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
19 changes: 11 additions & 8 deletions
19
distribution/examples/extending-membrane/reusable-plugin-chains/README.md
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 |
|---|---|---|
| @@ -1,20 +1,23 @@ | ||
| # Reusable Plugin Chains | ||
|
|
||
| This example demonstrates how using a shared chain helps standardize both request and response handling while letting each API define its own behavior. Chains group plugins and interceptors into reusable components, significantly reducing redundancy and the overall size of your proxies.xml configuration, especially when managing multiple APIs. | ||
| This example demonstrates how shared chains helps standardize both request and response handling while letting each API define its own behavior. A chain groups plugins and interceptors into reusable components, significantly reducing redundancy and the overall size of your configuration, especially when managing multiple APIs. | ||
|
|
||
| ## **Running the Example** | ||
|
|
||
| ### **Running the Example** | ||
| 1. **Start the Router** | ||
| ```sh | ||
| ./router-service.sh # Linux/Mac | ||
| router-service.bat # Windows | ||
| ``` | ||
| 2. **Test the APIs:** | ||
| - **API 1 (Port 2000) → Returns `200 OK`** | ||
| - **API 1:** | ||
| ```sh | ||
| curl -i http://localhost:2000 | ||
| curl -i http://localhost:2000/foo | ||
| ``` | ||
| - **API 2 (Port 2001) → Returns `404 Not Found`** | ||
| Observe the gateway log output for 'Path: ...' | ||
| - **API 2:** | ||
| ```sh | ||
| curl -i http://localhost:2001 | ||
| ``` | ||
| 3. **Check `proxies.xml`** to see how chains are applied. | ||
| curl -i http://localhost:2000/bar | ||
| ``` | ||
| Observe the gateway output and the response HTTP headers | ||
| 3. **Check `apis.yaml`** to see how chains are applied. |
45 changes: 45 additions & 0 deletions
45
distribution/examples/extending-membrane/reusable-plugin-chains/apis.yaml
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,45 @@ | ||
| # yaml-language-server: $schema=https://www.membrane-api.io/v7.0.5.json | ||
|
|
||
| components: | ||
| log: | ||
| chainDef: | ||
| flow: | ||
| - request: | ||
| - log: | ||
| message: "Path: ${path}" | ||
| cors: | ||
| chainDef: | ||
| flow: | ||
| - response: | ||
| - setHeader: | ||
| name: Access-Control-Allow-Origin | ||
| value: "*" | ||
| - setHeader: | ||
| name: Access-Control-Allow-Methods | ||
| value: POST, PUT | ||
| --- | ||
|
|
||
| api: | ||
| port: 2000 | ||
| path: | ||
| uri: /foo | ||
| flow: | ||
| - chain: | ||
| ref: '#/components/log' | ||
| - return: | ||
| status: 200 | ||
| --- | ||
|
|
||
| api: | ||
| port: 2000 | ||
| path: | ||
| uri: /bar | ||
| flow: | ||
| - chain: | ||
| # Chains can be applied to more than one API | ||
| ref: '#/components/log' | ||
| - chain: | ||
| # Referencing long chains can keep API definitions small and comprehensible | ||
| ref: '#/components/cors' | ||
| - return: | ||
| status: 200 |
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
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.