mirror of
https://github.com/DefectingCat/candy
synced 2025-07-15 16:51:34 +00:00
add mime types
This commit is contained in:
3
TODO.md
3
TODO.md
@ -3,8 +3,9 @@
|
||||
- [x] Graceful shutdown
|
||||
- [x] `keep-alive` timeout setting
|
||||
- [x] HTTP Etag: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag#etag_value
|
||||
- [ ] Content compress
|
||||
- [x] Content compress
|
||||
- [x] zstd
|
||||
- [x] gzip
|
||||
- [x] deflate
|
||||
- [x] br
|
||||
- [ ] File MIME type
|
||||
|
55
src/http/mime.rs
Normal file
55
src/http/mime.rs
Normal file
@ -0,0 +1,55 @@
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
||||
|
||||
macro_rules! mime {
|
||||
($a:ident, $b:literal) => {
|
||||
pub const $a: &str = $b;
|
||||
};
|
||||
}
|
||||
|
||||
mime!(TEXT_PLAIN, "text/plain");
|
||||
mime!(TEXT_PLAIN_UTF_8, "text/plain; charset=utf-8");
|
||||
mime!(TEXT_HTML, "text/html");
|
||||
mime!(TEXT_HTML_UTF_8, "text/html; charset=utf-8");
|
||||
mime!(TEXT_CSS, "text/css");
|
||||
mime!(TEXT_CSS_UTF_8, "text/css; charset=utf-8");
|
||||
mime!(TEXT_JAVASCRIPT, "text/javascript");
|
||||
mime!(TEXT_XML, "text/xml");
|
||||
mime!(TEXT_EVENT_STREAM, "text/event-stream");
|
||||
mime!(TEXT_CSV, "text/csv");
|
||||
mime!(TEXT_CSV_UTF_8, "text/csv; charset=utf-8");
|
||||
mime!(TEXT_TAB_SEPARATED_VALUES, "text/tab-separated-values");
|
||||
mime!(
|
||||
TEXT_TAB_SEPARATED_VALUES_UTF_8,
|
||||
"text/tab-separated-values; charset=utf-8"
|
||||
);
|
||||
mime!(TEXT_VCARD, "text/vcard");
|
||||
|
||||
mime!(IMAGE_JPEG, "image/jpeg");
|
||||
mime!(IMAGE_GIF, "image/gif");
|
||||
mime!(IMAGE_PNG, "image/png");
|
||||
mime!(IMAGE_BMP, "image/bmp");
|
||||
mime!(IMAGE_SVG, "image/svg+xml");
|
||||
|
||||
mime!(FONT_WOFF, "font/woff");
|
||||
mime!(FONT_WOFF2, "font/woff2");
|
||||
|
||||
mime!(APPLICATION_JSON, "application/json");
|
||||
mime!(APPLICATION_JAVASCRIPT, "application/javascript");
|
||||
mime!(
|
||||
APPLICATION_JAVASCRIPT_UTF_8,
|
||||
"application/javascript; charset=utf-8"
|
||||
);
|
||||
mime!(
|
||||
APPLICATION_WWW_FORM_URLENCODED,
|
||||
"application/x-www-form-urlencoded"
|
||||
);
|
||||
mime!(APPLICATION_OCTET_STREAM, "application/octet-stream");
|
||||
mime!(APPLICATION_MSGPACK, "application/msgpack");
|
||||
mime!(APPLICATION_PDF, "application/pdf");
|
||||
mime!(APPLICATION_DNS, "application/dns-message");
|
||||
|
||||
mime!(STAR_STAR, "*/*");
|
||||
mime!(TEXT_STAR, "text/*");
|
||||
mime!(IMAGE_STAR, "image/*");
|
||||
mime!(VIDEO_STAR, "video/*");
|
||||
mime!(AUDIO_STAR, "audio/*");
|
@ -1,4 +1,5 @@
|
||||
pub mod cache;
|
||||
pub mod mime;
|
||||
pub mod response;
|
||||
|
||||
pub use response::*;
|
||||
|
Reference in New Issue
Block a user