Rack middleware for internal click detection