rack middleware for statistics