5
5
6
6
from errno import EAGAIN , ECONNRESET
7
7
8
+ from .methods import HTTPMethod
8
9
from .request import _HTTPRequest
9
10
from .response import HTTPResponse
10
11
from .status import HTTPStatus
@@ -26,11 +27,11 @@ def __init__(self, socket_source: Any) -> None:
26
27
self ._sock = None
27
28
self .root_path = "/"
28
29
29
- def route (self , path : str , method : str = " GET" ):
30
+ def route (self , path : str , method : HTTPMethod = HTTPMethod . GET ):
30
31
"""Decorator used to add a route.
31
32
32
33
:param str path: filename path
33
- :param str method: HTTP method: " GET", " POST" , etc.
34
+ :param HTTPMethod method: HTTP method: HTTPMethod. GET, HTTPMethod. POST, etc.
34
35
35
36
Example::
36
37
@@ -99,7 +100,7 @@ def poll(self):
99
100
route = self .routes .get (request , None )
100
101
if route :
101
102
response = route (request )
102
- elif request .method == " GET" :
103
+ elif request .method == HTTPMethod . GET :
103
104
response = HTTPResponse (filename = request .path , root = self .root_path )
104
105
else :
105
106
response = HTTPResponse (status = HTTPStatus .INTERNAL_SERVER_ERROR )
0 commit comments