1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-13 02:39:32 +00:00
actix-web/src/http/header/content_language.rs

57 lines
1.7 KiB
Rust
Raw Normal View History

use super::{QualityItem, CONTENT_LANGUAGE};
2019-02-07 21:24:24 +00:00
use language_tags::LanguageTag;
2021-06-25 11:25:50 +00:00
crate::http::header::common_header! {
2019-02-07 21:24:24 +00:00
/// `Content-Language` header, defined in
/// [RFC7231](https://tools.ietf.org/html/rfc7231#section-3.1.3.2)
///
/// The `Content-Language` header field describes the natural language(s)
/// of the intended audience for the representation. Note that this
/// might not be equivalent to all the languages used within the
/// representation.
///
/// # ABNF
///
/// ```text
/// Content-Language = 1#language-tag
/// ```
///
/// # Example values
///
/// * `da`
/// * `mi, en`
///
/// # Examples
///
2021-01-15 02:11:10 +00:00
/// ```
/// use actix_web::HttpResponse;
/// use actix_web::http::header::{ContentLanguage, LanguageTag, qitem};
2021-01-15 02:11:10 +00:00
///
/// let mut builder = HttpResponse::Ok();
2021-01-15 02:11:10 +00:00
/// builder.insert_header(
2019-02-07 21:24:24 +00:00
/// ContentLanguage(vec![
/// qitem(LanguageTag::parse("en").unwrap()),
2019-02-07 21:24:24 +00:00
/// ])
/// );
/// ```
///
2021-01-15 02:11:10 +00:00
/// ```
/// use actix_web::HttpResponse;
/// use actix_web::http::header::{ContentLanguage, LanguageTag, qitem};
2019-02-07 21:24:24 +00:00
///
/// let mut builder = HttpResponse::Ok();
2021-01-15 02:11:10 +00:00
/// builder.insert_header(
2019-02-07 21:24:24 +00:00
/// ContentLanguage(vec![
/// qitem(LanguageTag::parse("da").unwrap()),
/// qitem(LanguageTag::parse("en-GB").unwrap()),
2019-02-07 21:24:24 +00:00
/// ])
/// );
/// ```
(ContentLanguage, CONTENT_LANGUAGE) => (QualityItem<LanguageTag>)+
test_content_language {
2021-06-25 11:25:50 +00:00
crate::http::header::common_header_test!(test1, vec![b"da"]);
crate::http::header::common_header_test!(test2, vec![b"mi, en"]);
2019-02-07 21:24:24 +00:00
}
}