{ "info": { "author": "Yang Fei", "author_email": "amyangfei@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "GoReplay Middleware\n===================\n\nPython library for `GoReplay Middleware `_ , API is quite similar to `NodeJS library `_\n\n.. image:: https://badge.fury.io/py/gor.svg\n :target: https://badge.fury.io/py/gor\n.. image:: https://travis-ci.org/amyangfei/GorMW.svg?branch=master\n :target: https://travis-ci.org/amyangfei/GorMW\n\nInstallation\n------------\n\nTo install GorMW, simply:\n\n.. code-block:: bash\n\n $ pip install gor\n\nor from source:\n\n.. code-block:: bash\n\n python setup.py install\n\nGetting Started\n---------------\n\nInitialize a TornadoGor based middleware and start it in the following way:\n\n.. code-block:: python\n\n from gor.middleware import TornadoGor\n proxy = TornadoGor()\n proxy.run()\n\nBasic idea is that you write callbacks which respond to request, response, replay, or message events, which contains request meta information and actuall http paylod. Depending on your needs you may compare, override or filter incoming requests and responses.\n\nYou can respond to the incoming events using on function, by providing callbacks:\n\n.. code-block:: python\n\n def on_request(proxy, msg, **kwargs):\n # do anything you want with msg\n # msg is a GorMessage object\n pass\n\n proxy = TornadoGor()\n proxy.on('request', on_request)\n proxy.run()\n\nYou can provide request ID as additional argument to on function, which allow you to map related requests and responses. Below is example of middleware which checks that original and replayed response have same HTTP status code.\n\n.. code-block:: python\n\n # coding: utf-8\n import sys\n from gor.middleware import TornadoGor\n\n\n def on_request(proxy, msg, **kwargs):\n proxy.on('response', on_response, idx=msg.id, req=msg)\n\n def on_response(proxy, msg, **kwargs):\n proxy.on('replay', on_replay, idx=kwargs['req'].id, req=kwargs['req'], resp=msg)\n\n def on_replay(proxy, msg, **kwargs):\n replay_status = proxy.http_status(msg.http)\n resp_status = proxy.http_status(kwargs['resp'].http)\n if replay_status != resp_status:\n sys.stderr.write('replay status [%s] diffs from response status [%s]\\n' % (replay_status, resp_status))\n else:\n sys.stderr.write('replay status is same as response status\\n')\n sys.stderr.flush()\n\n if __name__ == '__main__':\n proxy = TornadoGor()\n proxy.on('request', on_request)\n proxy.run()\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/amyangfei/GorMW", "keywords": "GoReplay Middleware", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "gor", "package_url": "https://pypi.org/project/gor/", "platform": "", "project_url": "https://pypi.org/project/gor/", "project_urls": { "Homepage": "http://github.com/amyangfei/GorMW" }, "release_url": "https://pypi.org/project/gor/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Python library for GoReplay Middleware", "version": "0.1.2" }, "last_serial": 3227647, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "961ced990e2b9095ec524c406db3c412", "sha256": "fd93d5deceec0469cab4cc21fcc90c9a21a6d0b1393951f67a80a851ee467692" }, "downloads": -1, "filename": "gor-0.1.1.tar.gz", "has_sig": false, "md5_digest": "961ced990e2b9095ec524c406db3c412", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4590, "upload_time": "2017-10-05T10:50:31", "url": "https://files.pythonhosted.org/packages/91/47/2879c3964143bf297dbc218b99888e22cbb79422bf425cf4933141a0aeb6/gor-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "39212d41cf920b0cd9be49df233796c9", "sha256": "eae8a2f31fd43386febfb0ebc4d5e77269e9258ddce0344709288a639f8ab327" }, "downloads": -1, "filename": "gor-0.1.2.tar.gz", "has_sig": false, "md5_digest": "39212d41cf920b0cd9be49df233796c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4586, "upload_time": "2017-10-05T10:56:40", "url": "https://files.pythonhosted.org/packages/ff/6c/2a92e4cee19a705710a816fc5e50f5250e9d30c9d9b0788e4b0e490168aa/gor-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "39212d41cf920b0cd9be49df233796c9", "sha256": "eae8a2f31fd43386febfb0ebc4d5e77269e9258ddce0344709288a639f8ab327" }, "downloads": -1, "filename": "gor-0.1.2.tar.gz", "has_sig": false, "md5_digest": "39212d41cf920b0cd9be49df233796c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4586, "upload_time": "2017-10-05T10:56:40", "url": "https://files.pythonhosted.org/packages/ff/6c/2a92e4cee19a705710a816fc5e50f5250e9d30c9d9b0788e4b0e490168aa/gor-0.1.2.tar.gz" } ] }