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

Introduce an aws-lambda feature. #2035

Merged
merged 6 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rust-runtime/aws-smithy-http-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Server runtime for Smithy Rust Server Framework.
publish = true

[features]
aws-lambda = ["lambda_http"]
unredacted-logging = []

[dependencies]
Expand All @@ -26,7 +27,7 @@ futures-util = { version = "0.3", default-features = false }
http = "0.2"
http-body = "0.4"
hyper = { version = "0.14.12", features = ["server", "http1", "http2", "tcp", "stream"] }
lambda_http = "0.7.1"
lambda_http = { version = "0.7.1", optional = true }
mime = "0.3"
nom = "7"
pin-project-lite = "0.2"
Expand Down
3 changes: 2 additions & 1 deletion rust-runtime/aws-smithy-http-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg_attr(docsrs, feature(doc_cfg))]

//! HTTP server runtime and utilities, loosely based on [axum].
//!
//! [axum]: https://docs.rs/axum/latest/axum/

#[macro_use]
pub(crate) mod macros;

Expand Down
2 changes: 2 additions & 0 deletions rust-runtime/aws-smithy-http-server/src/rejection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ convert_to_request_rejection!(std::str::Utf8Error, InvalidUtf8);
convert_to_request_rejection!(hyper::Error, HttpBody);

// Required in order to accept Lambda HTTP requests using `Router<lambda_http::Body>`.
#[cfg(feature = "aws-lambda")]
#[cfg_attr(docsrs, doc(cfg(feature = "aws-lambda")))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provides the feature-flag information next to the type/module in the docs - e.g.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice touch

convert_to_request_rejection!(lambda_http::Error, HttpBody);

pub mod any_rejections {
Expand Down
4 changes: 4 additions & 0 deletions rust-runtime/aws-smithy-http-server/src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use tower_http::map_response_body::MapResponseBodyLayer;

mod future;
mod into_make_service;
#[cfg(feature = "aws-lambda")]
#[cfg_attr(docsrs, doc(cfg(feature = "aws-lambda")))]
mod lambda_handler;

#[doc(hidden)]
Expand All @@ -38,6 +40,8 @@ mod route;

pub(crate) mod tiny_map;

#[cfg(feature = "aws-lambda")]
#[cfg_attr(docsrs, doc(cfg(feature = "aws-lambda")))]
pub use self::lambda_handler::LambdaHandler;
pub use self::{future::RouterFuture, into_make_service::IntoMakeService, route::Route};

Expand Down