How to use the faust.web.exceptions.WebError function in faust

To help you get started, we’ve selected a few faust examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github actorcloud / ActorCloud / server / app / services / tasks_scheduler / async_tasks / app / validate.py View on Github external
async def validate_request(request: Request, request_type: AnyStr) -> Dict:
    if not request.body_exists:
        raise WebError(code=400, detail='BAD_REQUEST')
    try:
        request_json = await request.json(loads=ujson_loads)
    except ValueError:
        raise WebError(code=400, detail='BAD_REQUEST')
    if not request_json.get('taskID'):
        raise WebError(code=422, detail='taskID')
    if request_type == 'publish':
        request_json = await _validate_publish_request(request_json)
    elif request_type == 'excel':
        request_json = await _validate_excel_request(request_json)
        request_json['language'] = request.headers.get('Accept-Language')
    return request_json