Skip to content
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

Merged
merged 12 commits into from
Nov 25, 2022
39 changes: 38 additions & 1 deletion rust-runtime/aws-smithy-http-server/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,47 @@
* SPDX-License-Identifier: Apache-2.0
*/

//! The plugin system allows for parameterized modification of [`Operation`]s during the build procedure.
//! The plugin system allows the user to build middleware with an awareness of the operation its applied to.
hlbarber marked this conversation as resolved.
Show resolved Hide resolved
//!
//! 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");
Copy link
Contributor

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.

//! ```
//!
//! # 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::empty()
hlbarber marked this conversation as resolved.
Show resolved Hide resolved
//! .push(a)
//! .push(b);
//! ```
//!

mod closure;
mod filter;
Expand Down
2 changes: 1 addition & 1 deletion rust-runtime/aws-smithy-http-server/src/routing/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct Route<B = Body> {
}

impl<B> Route<B> {
/// Constructs a new [`Route`] from any well-formed HTTP service which is cloneable.
/// Constructs a new [`Route`] from a well-formed HTTP service which is cloneable.
pub fn new<T>(svc: T) -> Self
where
T: Service<Request<B>, Response = Response<BoxBody>, Error = Infallible> + Clone + Send + 'static,
Expand Down