-
Notifications
You must be signed in to change notification settings - Fork 361
lambda_http: Make extension methods available for http::request::Parts
#607
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
Conversation
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.
Thanks for this contribution. It looks like there are some breaking changes. I think they need some more consideration.
Yes, there are quite a few breaking changes. More than you've commented on. I've detailed them in #606. I just want to make sure you're aware. |
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.
These two breaking changes need to be reverted too:
fn request_context(&self) -> RequestContext becomes
fn request_context(&self) -> Option<&RequestContext>
fn lambda_context(&self) -> Context becomes
fn lambda_context(&self) -> Option<&Context>
Done. |
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.
I just noticed that the module's name also changed, from RequestExt
to ExtensionsExt
. Please revert that, we don't want to make such major breaking changes without good reasons. That can erode customer trust.
It's been broken into two traits. pub trait ExtensionsExt {
fn raw_http_path(&self) -> &str;
fn with_raw_http_path<S>(self, path: S) -> Self
where
S: Into<String>;
fn query_string_parameters(&self) -> QueryMap;
fn query_string_parameters_ref(&self) -> Option<&QueryMap>;
fn with_query_string_parameters<Q>(self, parameters: Q) -> Self
where
Q: Into<QueryMap>;
fn path_parameters(&self) -> QueryMap;
fn path_parameters_ref(&self) -> Option<&QueryMap>;
fn with_path_parameters<P>(self, parameters: P) -> Self
where
P: Into<QueryMap>;
fn stage_variables(&self) -> QueryMap;
fn stage_variables_ref(&self) -> Option<&QueryMap>;
#[cfg(test)]
fn with_stage_variables<V>(self, variables: V) -> Self
where
V: Into<QueryMap>;
fn request_context(&self) -> RequestContext;
fn request_context_ref(&self) -> Option<&RequestContext>;
fn with_request_context(self, context: RequestContext) -> Self;
fn lambda_context(&self) -> Context;
fn lambda_context_ref(&self) -> Option<&Context>;
fn with_lambda_context(self, context: Context) -> Self;
}
impl ExtensionsExt for http::Extensions { ... }
impl ExtensionsExt for http::Parts { ... }
impl<B> ExtensionsExt for http::Request<B> { ... } pub trait RequestExt {
fn payload<D>(&self) -> Result<Option<D>, PayloadError>
where
for<'de> D: Deserialize<'de>;
}
impl RequestExt for lambda_http::Request { ... } I can rename |
|
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.
Thanks for working on this! LGTM
Thank you for reviewing it. |
Closes #606.
Adds extension methods to
http::request::Parts
andhttp::Extensions
, which allows the methods to be used after callingRequest::into_parts()
in addition to on the request itself. Closes #606, which has more detailed info.By submitting this pull request