Files
monasca-api/monasca_api/middleware/inspector.py
LiuNanke be8ea6c826 Clean up removed hacking rule from [flake8] ignore lists
We bump hacking>=0.10.0, and hacking removed some rules, for
the full list of rules please see [1]. So don't need them any more.

Hacking related commits:
Remove H904 in commit b1fe19ebebe47a36b905d709467f5e82521bbd96
Remove H803 in commit f01ce4fd822546cbd52a0aedc49184bddbfe1b10
Remove H307 in commit ec4833b206c23b0b6f9c6b101c70ab925a5e9c67
Remove H305 in commit 8f1fcbdb9aa4fc61349e5e879153c722195b1233

[1]https://github.com/openstack-dev/hacking/blob/master/setup.cfg#L30

Change-Id: Ia20b3570c1a28b3431a9115599a4a11366489edc
2016-01-24 20:45:08 +08:00

50 lines
1.5 KiB
Python

# Copyright 2013 IBM Corp
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class Inspector(object):
"""The middleware that logs the request body and header
This is a middleware for debug purposes. To enable this middleware, add
the following lines into the configuration file, for example:
[pipeline:main]
pipeline = inspector api
[filter:inspector]
use = egg: monasca_api_server#inspector
"""
def __init__(self, app, conf):
"""Inspect each request
:param app: OptionParser to use. If not sent one will be created.
:param conf: Override sys.argv; used in testing
"""
self.app = app
self.conf = conf
print('Inspect config:', self.conf)
def __call__(self, environ, start_response):
print('environ is ', environ)
return self.app(environ, start_response)
def filter_factory(global_conf, **local_conf):
def login_filter(app):
return Inspector(app, local_conf)
return login_filter