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

Make SigningInstructions public #2730

Merged
merged 6 commits into from
May 26, 2023
Merged
Changes from all commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
@@ -62,3 +62,9 @@ message = "For event stream operations, the `EventStreamSender` in inputs/output
references = ["smithy-rs#2673"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "all"}
author = "jdisanti"

[[aws-sdk-rust]]
message = "The `SigningInstructions` in the `aws-sigv4` module are now public. This allows them to be named in a function signature."
references = ["smithy-rs#2730"]
author = "cholcombe973"
meta = { "breaking" = false, "tada" = false, "bug" = true }
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-sigv4/src/http_request/mod.rs
Original file line number Diff line number Diff line change
@@ -56,4 +56,4 @@ pub use settings::{
PayloadChecksumKind, PercentEncodingMode, SessionTokenMode, SignatureLocation, SigningParams,
SigningSettings, UriPathNormalizationMode,
};
pub use sign::{sign, SignableBody, SignableRequest};
pub use sign::{sign, SignableBody, SignableRequest, SigningInstructions};
8 changes: 8 additions & 0 deletions aws/rust-runtime/aws-sigv4/src/http_request/sign.rs
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ pub enum SignableBody<'a> {
StreamingUnsignedPayloadTrailer,
}

/// Instructions for applying a signature to an HTTP request.
#[derive(Debug)]
pub struct SigningInstructions {
headers: Option<HeaderMap<HeaderValue>>,
@@ -117,20 +118,27 @@ impl SigningInstructions {
Self { headers, params }
}

/// Returns a reference to the headers that should be added to the request.
pub fn headers(&self) -> Option<&HeaderMap<HeaderValue>> {
self.headers.as_ref()
}

/// Returns the headers and sets the internal value to `None`.
pub fn take_headers(&mut self) -> Option<HeaderMap<HeaderValue>> {
self.headers.take()
}

/// Returns a reference to the query parameters that should be added to the request.
pub fn params(&self) -> Option<&Vec<(&'static str, Cow<'static, str>)>> {
self.params.as_ref()
}

/// Returns the query parameters and sets the internal value to `None`.
pub fn take_params(&mut self) -> Option<Vec<(&'static str, Cow<'static, str>)>> {
self.params.take()
}

/// Applies the instructions to the given `request`.
pub fn apply_to_request<B>(mut self, request: &mut http::Request<B>) {
if let Some(new_headers) = self.take_headers() {
for (name, value) in new_headers.into_iter() {