Skip to content

Commit

Permalink
add aiohttp add_view and serve_directory context features
Browse files Browse the repository at this point in the history
  • Loading branch information
buxx committed Jan 28, 2019
1 parent a4a7c75 commit 2ad8d18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 6 additions & 4 deletions example/example_serpyco_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ async def get_user(request, hapic_data: HapicData):
web.get(r'/user/{id}', get_user),
])

context = AiohttpContext(
app,
default_error_builder=SerpycoDefaultErrorBuilder()
)
hapic.set_context(
AiohttpContext(
app,
default_error_builder=SerpycoDefaultErrorBuilder()
)
context
)
hapic.add_documentation_view("/api/doc")
print(json.dumps(hapic.generate_doc()))
web.run_app(app)
6 changes: 2 additions & 4 deletions hapic/ext/aiohttp/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,10 @@ def add_view(
http_method: str,
view_func: typing.Callable[..., typing.Any],
) -> None:
# TODO BS 2018-07-15: to do
raise NotImplementedError("todo")
self.app.router.add_routes([web.route(http_method, path=route, handler=view_func)])

def serve_directory(self, route_prefix: str, directory_path: str) -> None:
# TODO BS 2018-07-15: to do
raise NotImplementedError("todo")
self.app.router.add_static(route_prefix, path=directory_path)

def is_debug(self,) -> bool:
return self._debug
Expand Down

0 comments on commit 2ad8d18

Please sign in to comment.