Crate tide_content_type_filter

Crate tide_content_type_filter 

Source
Expand description

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"]));

Structs§

ContentTypeFilter
A middleware for filtering requests based on their Content-Type.