Expand description

Actix Middleware - ETag

To avoid sending unnecessary bodies downstream, this middleware handles comparing If-None-Match headers to the calculated hash of the body of the GET request. Inspired by Node’s express framework and how it does ETag calculation, this middleware behaves in a similar fashion.

First hash the resulting body, then base64 encode the hash and set this as the ETag header for the GET request.

This does not save CPU resources on server side, since the body is still being calculated.

Beware: This middleware does not look at headers, so if you need to refresh your headers even if body is exactly the same, use something else (or better yet, add a PR on this repo adding a sane way to adhere to headers as well)

Structs

This should be loaded as the last middleware, as in, first in the sequence of wrap() Actix loads middlewares in bottom up fashion, and we want to have the resulting body from processing the entire request
The service holder for the transform that should happen