1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-05-20 09:18:26 +00:00
actix-web/actix-web/src/http/header/content_language.rs

55 lines
1.7 KiB
Rust
Raw Normal View History

2019-02-07 21:24:24 +00:00
use language_tags::LanguageTag;
2021-12-02 15:25:39 +00:00
use super::{common_header, QualityItem, CONTENT_LANGUAGE};
common_header! {
/// `Content-Language` header, defined
/// in [RFC 7231 §3.1.3.2](https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.3.2)
2019-02-07 21:24:24 +00:00
///
/// 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
2021-12-02 15:25:39 +00:00
/// ```plain
2019-02-07 21:24:24 +00:00
/// Content-Language = 1#language-tag
/// ```
///
/// # Example Values
2019-02-07 21:24:24 +00:00
/// * `da`
/// * `mi, en`
///
/// # Examples
2021-01-15 02:11:10 +00:00
/// ```
/// use actix_web::HttpResponse;
/// use actix_web::http::header::{ContentLanguage, LanguageTag, QualityItem};
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![
/// QualityItem::max(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, QualityItem};
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![
/// QualityItem::max(LanguageTag::parse("da").unwrap()),
/// QualityItem::max(LanguageTag::parse("en-GB").unwrap()),
2019-02-07 21:24:24 +00:00
/// ])
/// );
/// ```
(ContentLanguage, CONTENT_LANGUAGE) => (QualityItem<LanguageTag>)+
test_parse_and_format {
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
}
}