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
Feature | Getters for Response Status Code & Data Length Properties #186
Feature | Getters for Response Status Code & Data Length Properties #186
Conversation
This is a naive implementation on Request/Response logger using a fork of `tiny-http` where the status_code and the content_length is available. Depends on: - tiny-http/tiny-http#186
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'm not one of the regular maintainers here, but since your PR has been long without review, I'll have a go at it.
src/response.rs
Outdated
@@ -436,6 +436,16 @@ where | |||
|
|||
Ok(()) | |||
} | |||
|
|||
/// Retrieves the current value of the `Response` status code | |||
pub fn get_status_code(&self) -> StatusCode { |
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 think the "get_" prefix is not used anywhere else in the public API:s of this codebase. status_code
and data_length
would do fine
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.
Sure thing! I will replace those with the names suggested!
src/response.rs
Outdated
|
||
/// Retrieves the current value of the `Response` data length | ||
pub fn get_data_length(&self) -> Option<usize> { | ||
self.data_length.clone() |
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.
.clone()
is superfluous here. Option<usize>
is Copy
https://doc.rust-lang.org/std/option/enum.Option.html#impl-Copy
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.
Ohh! Thanks for sharing! Fixing it right away!
Implements two methods on `Response` `struct`. 1. `status_code` 2. `data_length` To act as "Getters" for these private properties in case they are needed by the client.
887902e
to
da15188
Compare
Implements two methods on
Response
struct
.status_code
data_length
To act as "Getters" for these private properties in case they are needed by the client.
Im using these methods in an HTTP Server I'm writing, these could help me get both values for logging purposes.