[lib] small fixes

This commit is contained in:
Maxime Alves LIRMM 2021-11-30 01:46:30 +01:00
parent 7c2bf60812
commit 7017827b2b
3 changed files with 5 additions and 4 deletions

View File

@ -51,9 +51,9 @@ def args_check(fct):
data_ = {}
if req.method == 'GET':
data_ = req.query_params
data_ = dict(req.query_params)
if req.method in ['POST', 'PATCH', 'PUT', 'DELETE']:
elif req.method in ['POST', 'PATCH', 'PUT', 'DELETE']:
try:
data_ = await req.json()
except JSONDecodeError as exc:

View File

@ -3,7 +3,7 @@ from schema import Schema, Optional
VERBS = ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')
ACLS_SCHEMA = Schema([{
'acl': str,
'acl': lambda fct: isinstance(fct(), bool),
Optional('args'): {
Optional('required'): { str },
Optional('optional'): { str }

View File

@ -21,6 +21,7 @@ import yaml
from .domain import gen_router_routes, domain_acls, route_decorator
from .responses import ORJSONResponse
from .acl import args_check
from ..half_route import HalfRoute
from ..conf import DOMAINSDICT
@ -75,7 +76,7 @@ def gen_schema_routes(schema: Dict):
if not inspect.iscoroutinefunction(fct):
yield HalfRoute(path, route_decorator(fct), acls, verb)
else:
yield HalfRoute(path, fct, acls, verb)
yield HalfRoute(path, args_check(fct), acls, verb)
def gen_starlette_routes(d_domains: Dict[str, ModuleType]) -> Generator: