tide-content-type-filter

Crates.iotide-content-type-filter
lib.rstide-content-type-filter
version0.3.0
sourcesrc
created_at2021-08-19 16:06:27.661726
updated_at2021-08-25 00:13:15.018907
descriptionTide middleware to filter requests based on their Content-Type.
homepage
repositoryhttps://github.com/Bauke/tide-content-type-filter
max_upload_size
id439682
size21,289
Bauke (Bauke)

documentation

https://docs.rs/tide-content-type-filter

README

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.

Commit count: 4

cargo fmt