code: def start_response_callback(start_response, transaction_id):
          
          def callback(status, headers, exc_info=None):
              """Add our headers to response using a closure."""
              headers.append(('X-Transaction-Id', transaction_id))
              # Call upstream start_response
              start_response(status, headers, exc_info)
          return callback
docs: Intercept upstream start_response and adds our headers.