Tide middleware to filter requests based on their Content-Type. https://crates.io/crates/tide-content-type-filter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bauke 3792989b75
Add subtype wildcard filtering.
1 month ago
source Add subtype wildcard filtering. 1 month ago
tests Add subtype wildcard filtering. 1 month ago
.gitignore Initial commit! 🌠 1 month ago
Cargo.toml Add subtype wildcard filtering. 1 month ago
LICENSE-Apache Initial commit! 🌠 1 month ago
LICENSE-MIT Initial commit! 🌠 1 month ago
README.md Add subtype wildcard filtering. 1 month ago
rustfmt.toml Initial commit! 🌠 1 month ago

README.md

tide-content-type-filter

Tide middleware to filter requests based on their Content-Type.

As described in tide#805.

Example

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.

License

Licensed under either of

at your option.

Contribution

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.