File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,30 @@ header! {
3434 }
3535}
3636
37+ impl ContentType {
38+ /// A constructor to easily create a `Content-Type: application/json; charset=utf-8` header.
39+ pub fn json ( ) -> ContentType {
40+ ContentType ( mime ! ( Application /Json ; Charset =Utf8 ) )
41+ }
42+
43+ /// A constructor to easily create a `Content-Type: text/plain; charset=utf-8` header.
44+ pub fn plaintext ( ) -> ContentType {
45+ ContentType ( mime ! ( Text /Plain ; Charset =Utf8 ) )
46+ }
47+
48+ /// A constructor to easily create a `Content-Type: text/html; charset=utf-8` header.
49+ pub fn html ( ) -> ContentType {
50+ ContentType ( mime ! ( Text /Html ; Charset =Utf8 ) )
51+ }
52+
53+ /// A constructor to easily create a `Content-Type: image/jpeg` header.
54+ pub fn jpeg ( ) -> ContentType {
55+ ContentType ( mime ! ( Image /Jpeg ) )
56+ }
57+
58+ /// A constructor to easily create a `Content-Type: image/png` header.
59+ pub fn png ( ) -> ContentType {
60+ ContentType ( mime ! ( Image /Png ) )
61+ }
62+ }
3763bench_header ! ( bench, ContentType , { vec![ b"application/json; charset=utf-8" . to_vec( ) ] } ) ;
You can’t perform that action at this time.
0 commit comments