Crates.io | tide-content-type-filter |
lib.rs | tide-content-type-filter |
version | 0.3.0 |
source | src |
created_at | 2021-08-19 16:06:27.661726 |
updated_at | 2021-08-25 00:13:15.018907 |
description | Tide middleware to filter requests based on their Content-Type. |
homepage | |
repository | https://github.com/Bauke/tide-content-type-filter |
max_upload_size | |
id | 439682 |
size | 21,289 |
Tide middleware to filter requests based on their Content-Type.
As described in tide#805.
Only process requests with Content-Type: application/json
, returns HTTP
415 Unsupported Media Type for all other requests.
use tide_content_type_filter::ContentTypeFilter;
let mut server = tide::new();
server.with(ContentTypeFilter::only("application/json"));
Only process requests with Content-Type: image/png
or
Content-Type: image/jpeg
:
use tide_content_type_filter::ContentTypeFilter;
let mut server = tide::new();
server.with(ContentTypeFilter::any(vec!["image/png", "image/jpeg"]));
Any content type's subtype (the part after the /
) may also be a *
to act as a wildcard (ie. only match the base type, the part before the /
). So image/*
will match image/png
, image/jpeg
, etc.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.