diff options
Diffstat (limited to 'README.rst')
-rw-r--r-- | README.rst | 45 |
1 files changed, 43 insertions, 2 deletions
@@ -1,3 +1,4 @@ +======================== CORS support for aiohttp ======================== @@ -126,7 +127,7 @@ from git: $ pip install aiohttp_cors Note that ``aiohttp_cors`` requires versions of Python >= 3.4.1 and -``aiohttp`` >= 0.21.4. +``aiohttp`` >= 1.1. Usage ===== @@ -346,6 +347,46 @@ in the router: for route in list(app.router.routes()): cors.add(route) +You can also use ``CorsViewMixin`` on ``web.View``: + +.. code-block:: python + + class CorsView(web.View, CorsViewMixin): + + cors_config = { + "*": ResourceOption( + allow_credentials=True, + allow_headers="X-Request-ID", + ) + } + + @asyncio.coroutine + def get(self): + return web.Response(text="Done") + + @custom_cors({ + "*": ResourceOption( + allow_credentials=True, + allow_headers="*", + ) + }) + @asyncio.coroutine + def post(self): + return web.Response(text="Done") + + cors = aiohttp_cors.setup(app, defaults={ + "*": aiohttp_cors.ResourceOptions( + allow_credentials=True, + expose_headers="*", + allow_headers="*", + ) + }) + + cors.add( + app.router.add_route("*", "/resource", CorsView), + webview=True) + + Security ======== @@ -460,7 +501,7 @@ Post release steps: Bugs ==== -Please report bugs, issues, feature requests, etc. on +Please report bugs, issues, feature requests, etc. on `GitHub <https://github.com/aio-libs/aiohttp_cors/issues>`__. |