title: Flask middleware for specific route
body: <p>I made API Server with Python Flask-RESTful.</p>
  <p>My system use token authentication for verify permission.</p>
  <p>So, I added middleware for verify token.</p>
  <p>For example, code like this,</p>
  <p>[middleware.py]</p>
  <pre class="lang-py prettyprint-override"><code>class Test(object):
      def __init__(self, app):
          self.app = app
  
      def __call__(self, environ, start_response):
          print(&quot;gogo&quot;)
          return self.app(environ, start_response)
  </code></pre>
  <p>[app.py]</p>
  <pre class="lang-py prettyprint-override"><code>from flask import Flask
  from flask_restful import Api
  from api.board import Article
  from api.auth import Login, Register, RefreshToken
  from middleware import Test
  
  
  app = Flask(__name__)
  api = Api(app)
  
  api.add_resource(Login, '/login')
  api.add_resource(Register, '/register')
  api.add_resource(RefreshToken, '/refresh')
  
  # middleware here
  app.wsgi_app = Test(app.wsgi_app)
  api.add_resource(Article, '/article')
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  <p>I insert <code>app.wsgi_app = Test(app.wsgi_app)</code> before <code>/article</code>.</p>
  <p>So I expect that only access to <code>/article</code> will print <em>&quot;gogo&quot;</em>, however every route print <em>&quot;gogo&quot;</em>.</p>
  <p>Maybe every route pass through with middleware.</p>
  <p>How can I apply middleware for specific route? (In this code, only <code>/article</code>)</p>