-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Story
When declare a path with regex, parameters can't be delcared with a type.
Actual behaviour
All path parameters are string.
Steps to reproduce
from aiohttp import web
async def handle(request):
name = request.match_info.get('id', 42)
text = str(type(name))
return web.Response(text=text)
app = web.Application()
app.add_routes([web.get('/', handle),
web.get(r'/{id:\d+}', handle)])
web.run_app(app)
$ http :8080/42
HTTP/1.1 200 OK
Content-Length: 13
Content-Type: text/plain; charset=utf-8
Date: Tue, 20 Nov 2018 16:33:58 GMT
Server: Python/3.7 aiohttp/3.4.4
<class 'str'>
My question/issue
It exist a way to declare the type of path parameters ? I would like obtain an int
in this example.