As I understand it, middleware handlers are not suitable for this since they work before processing the request. My current solution is:
router.get("/items/:id", middleware! { |request, mut response|
// ...
let data = json::encode(&data).unwrap();
response.set(ContentLength(data.len() as u64));
data
});
I do not like this because I have many routes and I will have to insert this code in each of them. I would like a middleware which would be called after processing my routes. Is there another way?