Skip to content

Commit

Permalink
feat(header): add text() and text_utf8() constructors to `Content…
Browse files Browse the repository at this point in the history
…Type`
  • Loading branch information
seanmonstar committed Mar 22, 2018
1 parent eb10567 commit 45cf8c5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/header/common/content_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,23 @@ impl ContentType {
ContentType(mime::APPLICATION_JSON)
}

// Kind of deprecated, `text()` and `text_utf8()` are better.
// But don't bother with an actual #[deprecated], because the whole
// header system is changing in 0.12 anyways.
#[doc(hidden)]
pub fn plaintext() -> ContentType {
ContentType(mime::TEXT_PLAIN_UTF_8)
}

/// A constructor to easily create a `Content-Type: text/plain` header.
#[inline]
pub fn text() -> ContentType {
ContentType(mime::TEXT_PLAIN_UTF_8)
}

/// A constructor to easily create a `Content-Type: text/plain; charset=utf-8` header.
#[inline]
pub fn plaintext() -> ContentType {
pub fn text_utf8() -> ContentType {
ContentType(mime::TEXT_PLAIN_UTF_8)
}

Expand Down

0 comments on commit 45cf8c5

Please sign in to comment.