additional compat support
This commit is contained in:
parent
792a72bdf4
commit
5f79291b55
|
@ -1,6 +1,7 @@
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
from sanic_routing import BaseRouter
|
from sanic_routing import BaseRouter
|
||||||
|
from sanic_routing.route import Route
|
||||||
|
|
||||||
from sanic.constants import HTTP_METHODS
|
from sanic.constants import HTTP_METHODS
|
||||||
from sanic.log import logger
|
from sanic.log import logger
|
||||||
|
@ -21,9 +22,16 @@ class Router(BaseRouter):
|
||||||
# TODO: Implement response
|
# TODO: Implement response
|
||||||
# - args,
|
# - args,
|
||||||
# - endpoint,
|
# - endpoint,
|
||||||
# - ignore_body,
|
|
||||||
|
|
||||||
return handler, (), params, route.path, route.name, None, False
|
return (
|
||||||
|
handler,
|
||||||
|
(),
|
||||||
|
params,
|
||||||
|
route.path,
|
||||||
|
route.name,
|
||||||
|
None,
|
||||||
|
route.ctx.ignore_body,
|
||||||
|
)
|
||||||
|
|
||||||
def add(
|
def add(
|
||||||
self,
|
self,
|
||||||
|
@ -35,10 +43,18 @@ class Router(BaseRouter):
|
||||||
ignore_body=False,
|
ignore_body=False,
|
||||||
version=None,
|
version=None,
|
||||||
name=None,
|
name=None,
|
||||||
):
|
) -> Route:
|
||||||
# TODO: Implement
|
# TODO: Implement
|
||||||
# - host
|
# - host
|
||||||
# - strict_slashes
|
# - strict_slashes
|
||||||
# - version
|
|
||||||
# - ignore_body
|
# - ignore_body
|
||||||
super().add(path=uri, handler=handler, methods=methods, name=name)
|
if version is not None:
|
||||||
|
version = str(version).strip("/").lstrip("v")
|
||||||
|
uri = "/".join([f"/v{version}", uri.lstrip("/")])
|
||||||
|
|
||||||
|
route = super().add(
|
||||||
|
path=uri, handler=handler, methods=methods, name=name
|
||||||
|
)
|
||||||
|
route.ctx.ignore_body = ignore_body
|
||||||
|
|
||||||
|
return route
|
||||||
|
|
Loading…
Reference in New Issue
Block a user