示例#1
0
def put_resource(id):
    validation_errors = validate_resource(request, id)

    if validation_errors:
        return utils.standardize_response(payload=validation_errors,
                                          status_code=422)
    return update_resource(id, request.get_json(), db)
示例#2
0
def post_resources():
    validation_errors = validate_resource(request)

    if validation_errors:
        return utils.standardize_response(payload=validation_errors,
                                          status_code=422)
    return create_resource(request.get_json(), db)
def put_resource(id):
    json = request.get_json()

    if not isinstance(json, dict):
        return wrong_type("resource object", type(json))

    validation_errors = validate_resource(request.method, json, id)

    if validation_errors:
        errors = {"errors": validation_errors}
        return utils.standardize_response(payload=errors, status_code=422)
    return update_resource(id, request.get_json(), db)