{ "info": { "author": "Sergey Mokeyev", "author_email": "sergey.mokeyev@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: POSIX", "Programming Language :: Python :: 3.7" ], "description": "RESTService\n=====\n\n# About\nREST Service is small library.\nThis is template for REST services.\nREST Service is wrapper for [aiohttp](https://github.com/aio-libs/aiohttp) framework.\nThis library wraps class Application from framework and adds middleware for handle exceptions and make web response from it.\nAlso throws config file to web handlers. \n\n# Installation\n\n```bash\npip install restservice\n```\n\n# Classes\n\n- RESTService - class makes aiohttp app with middleware who catchs exceptions and makes web response \n- RESTConfig - class makes config and gets params from yaml file\n- RESTHandler - class wraps aiohttp View class and throws config in handler\n- RESTError - class for generate exceptions\n\n# Example\n\n```python\nfrom aiohttp.web import json_response, RouteTableDef\nfrom restservice import RESTError, RESTService, RESTConfig, RESTHandler\n\n\nroutes = RouteTableDef()\n\n\n# Create class Config with params as annotation\n# config gets env variable ENVIRONMENT and find params in yaml file\n# if config not found param with current env config gets param from DEFAULT or return None\nclass Config(RESTConfig):\n DB: str\n\n\n# make func handler\nasync def func_handler(request):\n return json_response(await request.json())\n\n\n# make class handler with config\n@routes.view(r'/test/{user_id}')\nclass TestHandler(RESTHandler):\n # GET handler\n async def get(self):\n user_id = self.request.match_info.get('user_id')\n db_path = self.config.DB\n if user_id == 'exc':\n raise RESTError('USER_ID_ERROR', 'User id error.')\n\n return json_response({'user_id': user_id, 'db_path': db_path})\n\n\nif __name__ == '__main__':\n app = RESTService() # create aiohttp app with middleware\n app.config = Config('config.yaml') # add config\n app.add_routes(routes) # add route table\n app.router.add_get('/example', func_handler) # add handler\n app.start() # run app\n\n```\n\nexample request not found page\n\n```bash\ncurl http://localhost:8080/404\n```\n\nresponse\n\n```json\n{\n \"error\": \"HTTP_NOT_FOUND\",\n \"message\": \"Http not found.\",\n \"detail\": null\n}\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SergeyMokeyev/RESTService", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "restservice", "package_url": "https://pypi.org/project/restservice/", "platform": "", "project_url": "https://pypi.org/project/restservice/", "project_urls": { "Homepage": "https://github.com/SergeyMokeyev/RESTService" }, "release_url": "https://pypi.org/project/restservice/0.1.10/", "requires_dist": null, "requires_python": "", "summary": "A small JSON API service template", "version": "0.1.10" }, "last_serial": 5467890, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "59074a869dba5d0cf808a04fc7bd1ad2", "sha256": "da078c8e8351899bcee43488ef7d606e18a003d1977737bd7c33e0ab67828cb6" }, "downloads": -1, "filename": "restservice-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "59074a869dba5d0cf808a04fc7bd1ad2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15868, "upload_time": "2019-06-26T08:09:39", "url": "https://files.pythonhosted.org/packages/ee/54/9df6e79c68c5c2ec415e9b7e7f5c06c233c9d770cd8d8f284e420e8bcd26/restservice-0.1.0-py3-none-any.whl" } ], "0.1.10": [ { "comment_text": "", "digests": { "md5": "a8879c3f9a2e9e2c47f7a52b6b33f1cd", "sha256": "3abd00a9367b91af325eaec2229ccaf929e9e31d642601d39f4815e7f5500165" }, "downloads": -1, "filename": "restservice-0.1.10.tar.gz", "has_sig": false, "md5_digest": "a8879c3f9a2e9e2c47f7a52b6b33f1cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3225, "upload_time": "2019-06-30T13:01:29", "url": "https://files.pythonhosted.org/packages/f9/bc/96bd7a8d5a1612f5de97cb241acf82fe8e39fe9e426358ed1d7b5f9f3282/restservice-0.1.10.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "733e42ae86fdeb99485cf71749c1ba4e", "sha256": "d503108892e5f5e2b80fba946db5d8325b28ff7273bd9d99882c71397716494a" }, "downloads": -1, "filename": "restservice-0.1.7.tar.gz", "has_sig": false, "md5_digest": "733e42ae86fdeb99485cf71749c1ba4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2171, "upload_time": "2019-06-26T07:35:02", "url": "https://files.pythonhosted.org/packages/f5/a5/1946fe3ccb4e0f7045c6bd2eb6641aed0af833b9ac43968f74ca9f875dbf/restservice-0.1.7.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "5a846685330a3043d21ae546bb0bf56c", "sha256": "1c472b1c5c5b0c7f2c8af6a6eea4e5803e6830f3f9428786de755238468fe75b" }, "downloads": -1, "filename": "restservice-0.1.8.tar.gz", "has_sig": false, "md5_digest": "5a846685330a3043d21ae546bb0bf56c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2197, "upload_time": "2019-06-26T08:02:30", "url": "https://files.pythonhosted.org/packages/a7/1a/97032d4232435b1eee5e75a2c8001a0619a36e3ffb10d692536574b0ad66/restservice-0.1.8.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "75dde89167f225468f4bbf1944a7e9ca", "sha256": "199c16ce0d4b47c81e1c7aaa9f62e96c8c2dcad38ef3fd9cd7978770fd95d9de" }, "downloads": -1, "filename": "restservice-0.1.9-py3-none-any.whl", "has_sig": false, "md5_digest": "75dde89167f225468f4bbf1944a7e9ca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15866, "upload_time": "2019-06-26T08:07:31", "url": "https://files.pythonhosted.org/packages/9b/69/167ac4f312d7afe824fad29f66028973f24c7bdf8df02550fa2917473c20/restservice-0.1.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e4963a68b1dfa70b40672afbf0a87db9", "sha256": "d66d4fee4db055c46acdc5b3b76b6898884439bf88e62cb2707f1e3976080ecf" }, "downloads": -1, "filename": "restservice-0.1.9.tar.gz", "has_sig": false, "md5_digest": "e4963a68b1dfa70b40672afbf0a87db9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2200, "upload_time": "2019-06-26T08:07:32", "url": "https://files.pythonhosted.org/packages/14/e4/1e36684287d58a7277695b371830d02ac8272b23793954c58c007a9f3ba6/restservice-0.1.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a8879c3f9a2e9e2c47f7a52b6b33f1cd", "sha256": "3abd00a9367b91af325eaec2229ccaf929e9e31d642601d39f4815e7f5500165" }, "downloads": -1, "filename": "restservice-0.1.10.tar.gz", "has_sig": false, "md5_digest": "a8879c3f9a2e9e2c47f7a52b6b33f1cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3225, "upload_time": "2019-06-30T13:01:29", "url": "https://files.pythonhosted.org/packages/f9/bc/96bd7a8d5a1612f5de97cb241acf82fe8e39fe9e426358ed1d7b5f9f3282/restservice-0.1.10.tar.gz" } ] }