Skip to content

Commit

Permalink
Merge pull request #95 from ROMemories/feat/support-html-content-type
Browse files Browse the repository at this point in the history
feat(headers): add support for the `text/html` `Content-Type`
  • Loading branch information
lulf authored Dec 18, 2024
2 parents c1f28a5 + 1b77c2e commit 2e8fc5f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ContentType {
TextHtml,
TextPlain,
ApplicationJson,
ApplicationCbor,
Expand All @@ -13,6 +14,7 @@ impl<'a> From<&'a [u8]> for ContentType {
match from {
b"application/json" => ContentType::ApplicationJson,
b"application/cbor" => ContentType::ApplicationCbor,
b"text/html" => ContentType::TextHtml,
b"text/plain" => ContentType::TextPlain,
_ => ContentType::ApplicationOctetStream,
}
Expand All @@ -22,6 +24,7 @@ impl<'a> From<&'a [u8]> for ContentType {
impl ContentType {
pub fn as_str(&self) -> &str {
match self {
ContentType::TextHtml => "text/html",
ContentType::TextPlain => "text/plain",
ContentType::ApplicationJson => "application/json",
ContentType::ApplicationCbor => "application/cbor",
Expand Down

0 comments on commit 2e8fc5f

Please sign in to comment.