-
Notifications
You must be signed in to change notification settings - Fork 196
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
Improve service documentation #2020
Changes from 8 commits
d452af5
0eb66dc
e2b094c
d717444
e441393
4a8a3f3
34bd266
9cdb820
c68ce6e
dd4b04a
00f9aaa
081715b
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 |
---|---|---|
|
@@ -3,6 +3,51 @@ | |
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
//! The plugin system allows you to build middleware with an awareness of the operation it is applied to. | ||
//! | ||
//! The system centers around the [`Plugin`] trait. In addition, this module provides helpers for composing and | ||
//! combining [`Plugin`]s. | ||
//! | ||
//! # Filtered application of a HTTP [`Layer`](tower::Layer) | ||
//! | ||
//! ``` | ||
//! # use aws_smithy_http_server::plugin::*; | ||
//! # let layer = (); | ||
//! // Create a `Plugin` from a HTTP `Layer` | ||
//! let plugin = HttpLayer(layer); | ||
//! | ||
//! // Only apply the layer to operations with name "GetPokemonSpecies" | ||
//! let plugin = filter_by_operation_name(plugin, |name| name == "GetPokemonSpecies"); | ||
//! ``` | ||
//! | ||
//! # Construct [`Plugin`] from Operation name closure | ||
hlbarber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//! | ||
//! ``` | ||
//! # use aws_smithy_http_server::plugin::*; | ||
//! // A `tower::Layer` which requires the operation name | ||
//! struct PrintLayer { | ||
//! name: &'static str | ||
//! } | ||
//! | ||
//! // Create a `Plugin` using `PrintLayer` | ||
//! let plugin = plugin_from_operation_name_fn(|name| PrintLayer { name }); | ||
//! ``` | ||
//! | ||
//! # Combine [`Plugin`]s | ||
//! | ||
//! ``` | ||
//! # use aws_smithy_http_server::plugin::*; | ||
//! # let a = (); let b = (); | ||
//! // Combine `Plugin`s `a` and `b` | ||
//! let plugin = PluginPipeline::new() | ||
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. What's the order in which they will run? 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. Good point, I'll document that 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. |
||
//! .push(a) | ||
//! .push(b); | ||
//! ``` | ||
//! | ||
//! As noted in the [`PluginPipeline`] documentation, the plugins' runtime logic is executed in registration order, | ||
//! meaning that `a` is run _before_ `b` in the example above. | ||
//! | ||
|
||
mod closure; | ||
mod filter; | ||
mod identity; | ||
|
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.
Let's use the
::NAME
property on an operation ZST here.