[lib] small fixes
This commit is contained in:
parent
7c2bf60812
commit
7017827b2b
@ -51,9 +51,9 @@ def args_check(fct):
|
|||||||
|
|
||||||
data_ = {}
|
data_ = {}
|
||||||
if req.method == 'GET':
|
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:
|
try:
|
||||||
data_ = await req.json()
|
data_ = await req.json()
|
||||||
except JSONDecodeError as exc:
|
except JSONDecodeError as exc:
|
||||||
|
@ -3,7 +3,7 @@ from schema import Schema, Optional
|
|||||||
VERBS = ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')
|
VERBS = ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')
|
||||||
|
|
||||||
ACLS_SCHEMA = Schema([{
|
ACLS_SCHEMA = Schema([{
|
||||||
'acl': str,
|
'acl': lambda fct: isinstance(fct(), bool),
|
||||||
Optional('args'): {
|
Optional('args'): {
|
||||||
Optional('required'): { str },
|
Optional('required'): { str },
|
||||||
Optional('optional'): { str }
|
Optional('optional'): { str }
|
||||||
|
@ -21,6 +21,7 @@ import yaml
|
|||||||
|
|
||||||
from .domain import gen_router_routes, domain_acls, route_decorator
|
from .domain import gen_router_routes, domain_acls, route_decorator
|
||||||
from .responses import ORJSONResponse
|
from .responses import ORJSONResponse
|
||||||
|
from .acl import args_check
|
||||||
from ..half_route import HalfRoute
|
from ..half_route import HalfRoute
|
||||||
from ..conf import DOMAINSDICT
|
from ..conf import DOMAINSDICT
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ def gen_schema_routes(schema: Dict):
|
|||||||
if not inspect.iscoroutinefunction(fct):
|
if not inspect.iscoroutinefunction(fct):
|
||||||
yield HalfRoute(path, route_decorator(fct), acls, verb)
|
yield HalfRoute(path, route_decorator(fct), acls, verb)
|
||||||
else:
|
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:
|
def gen_starlette_routes(d_domains: Dict[str, ModuleType]) -> Generator:
|
||||||
|
Loading…
Reference in New Issue
Block a user