Skip to content

Commit

Permalink
Merge pull request #80 from xsnippet/routes
Browse files Browse the repository at this point in the history
Move API routes into separate routes.py
  • Loading branch information
ikalnytskyi committed Apr 5, 2018
2 parents a44f4b4 + bb937a5 commit 31cc965
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 2 additions & 4 deletions xsnippet/api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import aiohttp.web
import picobox

from . import database, router, middlewares, resources
from . import database, router, routes, middlewares


async def _inject_vary_header(request, response):
Expand Down Expand Up @@ -59,9 +59,7 @@ def create_app(conf, db):
"""

v1 = aiohttp.web.UrlDispatcher()
v1.add_route('*', '/snippets', resources.Snippets)
v1.add_route('*', '/snippets/{id}', resources.Snippet)
v1.add_route('*', '/syntaxes', resources.Syntaxes)
v1.add_routes(routes.v1)

# We need to import all the resources in order to evaluate @endpoint
# decorator, so they can be collected and passed to VersionRouter.
Expand Down
12 changes: 12 additions & 0 deletions xsnippet/api/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Routes of various API versions."""

import aiohttp.web as web

from . import resources


v1 = [
web.route('*', '/snippets', resources.Snippets),
web.route('*', '/snippets/{id}', resources.Snippet),
web.route('*', '/syntaxes', resources.Syntaxes),
]

0 comments on commit 31cc965

Please sign in to comment.