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

Implement #1283 idea using typed headers #1538

Closed
wants to merge 6 commits into from

Conversation

jespersm
Copy link

This PR implements FromRequest for a number of the typed headers from the hyperxcrate.
It depends on PR #1535.

It allows for constructs such as:

use rocket::http::hyper::header::AcceptLanguage;

#[get("/poem")]
fn poem(lang: Option<AcceptLanguage>) -> String {
    if let Some(lang) = lang {
        format!("TODO: Write a poem in '{}'", lang)
    } else {
        format!("A poem in any other language would sound as sweet!")
    }
}

The list of headers may need to be looked at since a number of the supported typed headers are only used in responses.

@SergioBenitez
Copy link
Member

I am closing this as an implication of closing #1535.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants