title: Flask - access the request in after_request or teardown_request
body: <p>I want to be able to access the request object before I return the response of the HTTP call.
  I want access to the request via "teardown_request" and "after_request":</p>
  
  <pre><code>from flask import Flask
  ...
  app = Flask(__name__, instance_relative_config=True)
  ...
  
  @app.before_request
  def before_request():
      # do something
  
  @app.after_request
  def after_request(response):
      # get the request object somehow
      do_something_based_on_the_request_endpoint(request)
  
  @app.teardown_request
  def teardown_request(response):
      # get the request object somehow
      do_something_based_on_the_request_endpoint(request)
  </code></pre>
  
  <p>I saw that I can add the request to g and do something like this:</p>
  
  <pre><code>g.curr_request = request
  
  @app.after_request
  def after_request(response):
      # get the request object somehow
      do_something_based_on_the_request_endpoint(g.curr_request)
  </code></pre>
  
  <p>But the above seems a bit strange. I'm sure that there's a better way to access the request. </p>
  
  <p>Thanks</p>