-
Notifications
You must be signed in to change notification settings - Fork 105
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
Use strong typing for the response's headers #24
Comments
The objectives of that change would be:
However I really don't like hyper's strong typing system, as it's confusing, difficult to understand, and annoying to use. Rouille's API should remain as idiomatic as possible, and not use meta-programming techniques. In my opinion the new API should look like this: pub struct Response {
pub status_code: u16,
pub cache_control: ...,
pub content_type: ...,
pub cookies: Vec<Cookie>,
...
pub custom_headers: Vec<(String, String)>,
pub body: ResponseBody,
private_member_so_that_headers_can_be_added_later_without_a_breaking_change: (),
} However a good trade-off needs to be found between strong typing and usability. For example in my opinion the status code should remain a The problem that remains is how to handle headers that are specific to a status code, like |
The other problem is how to handle that with the cgi and reverse proxy features. |
I think we need the following changes:
|
The |
PR #65 is now mature enough to give a small idea of how it looks like. Things I noticed:
|
For now my conclusion is: negative, but let's postpone and not close it altogether. |
Is hyper's Headers implementation really that hard to use? It seems to me that their approach is the natural end-game for a strongly-typed approach to HTTP headers (modulo some improvements). The metaprogramming use is purely optional, and merely automates away the boilerplate. At the end, using it boils down to |
Instead of providing a single member
headers: Vec<(String, String)>
, the Response should have multiple members each corresponding to a header.The text was updated successfully, but these errors were encountered: