summaryrefslogtreecommitdiff
path: root/include/py/homekit/http
diff options
context:
space:
mode:
Diffstat (limited to 'include/py/homekit/http')
-rw-r--r--include/py/homekit/http/__init__.py4
-rw-r--r--include/py/homekit/http/http.py11
2 files changed, 12 insertions, 3 deletions
diff --git a/include/py/homekit/http/__init__.py b/include/py/homekit/http/__init__.py
index 6030e95..d019e4c 100644
--- a/include/py/homekit/http/__init__.py
+++ b/include/py/homekit/http/__init__.py
@@ -1,2 +1,2 @@
-from .http import serve, ok, routes, HTTPServer
-from aiohttp.web import FileResponse, StreamResponse, Request, Response
+from .http import serve, ok, routes, HTTPServer, HTTPMethod
+from aiohttp.web import FileResponse, StreamResponse, Request, Response \ No newline at end of file
diff --git a/include/py/homekit/http/http.py b/include/py/homekit/http/http.py
index 3e70751..82c5aae 100644
--- a/include/py/homekit/http/http.py
+++ b/include/py/homekit/http/http.py
@@ -1,8 +1,9 @@
import logging
import asyncio
+from enum import Enum
from aiohttp import web
-from aiohttp.web import Response
+from aiohttp.web import Response, HTTPFound
from aiohttp.web_exceptions import HTTPNotFound
from ..util import stringify, format_tb, Addr
@@ -20,6 +21,9 @@ async def errors_handler_middleware(request, handler):
except HTTPNotFound:
return web.json_response({'error': 'not found'}, status=404)
+ except HTTPFound as exc:
+ raise exc
+
except Exception as exc:
_logger.exception(exc)
data = {
@@ -104,3 +108,8 @@ class HTTPServer:
def plain(self, text: str):
return Response(text=text, content_type='text/plain')
+
+
+class HTTPMethod(Enum):
+ GET = 'GET'
+ POST = 'POST'