-
Notifications
You must be signed in to change notification settings - Fork 259
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
rust: Add some convenience methods/impls to http types #1977
Conversation
94d95a7
to
c8e0961
Compare
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 really appreciate the convenience these add.
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.
Nice!
c8e0961
to
70f50c9
Compare
And update rust outbound http examples to use "simple" types. - Add `Request::{get,post}` associated functions which cover the most common request types. - `impl TryIntoOutgoingRequest for RequestBuilder` to skip a boilerplate `.build()` - Add `Response::into_builder` to ease returning an updated response. - `impl Debug for Response` to fix examples Signed-off-by: Lann Martin <lann.martin@fermyon.com>
70f50c9
to
3821266
Compare
@@ -528,6 +530,16 @@ impl TryIntoOutgoingRequest for Request { | |||
} | |||
} | |||
|
|||
impl TryIntoOutgoingRequest for RequestBuilder { |
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.
We should probably do the same for IntoResponse for ResponseBuilder
.
f.debug_struct("Response") | ||
.field("status", &self.status) | ||
.field("headers", &self.headers) | ||
.field("body.len()", &self.body.len()) |
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 wonder if this would be more useful:
.field("body.", String::from_utf8_lossy(&self.body[..self.body.len().min(50)]))
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.
Probably!
This whole PR is summed up by this
http-rust-outbound-http
example diff.Draft until #1975 merges.
And update rust outbound http examples to use "simple" types.
Request::{get,post}
associated functions which cover the most common request types.impl TryIntoOutgoingRequest for RequestBuilder
to skip a boilerplate.build()
Response::into_builder
to ease returning an updated response.impl Debug for Response
to fix examples