Add to route headers?

I think this will help in resolving the issue
add to nginx
location /logs/messages.json {
}

add_header Cache-Control "no-store";
add_header Pragma "no-cache";

How to do this through middleware?

req = Rack::Request.new(@env)
    route = req.path_info.to_s
  if (route == '/logs/messages.json')
    #add headers
  end