コード例 #1
0
def serve_json(data, profile=None):
    content_type = 'application/json'
    if profile is not None:
        content_type += ';profile="%s"' % (profile,)
    response.set_content_type(content_type)
    response.set_data(json.dumps(data))
    return response._get_current_object()
コード例 #2
0
ファイル: constructors.py プロジェクト: mazen-hasoun/checkmk
def serve_json(data, profile=None):
    content_type = 'application/json'
    if profile is not None:
        content_type += ';profile="%s"' % (profile, )
    response.set_content_type(content_type)
    response.set_data(json.dumps(data))
    # HACK: See wrap_with_validation.
    response.original_data = data  # type: ignore[attr-defined]
    # TODO: Why don't we just return response? We access a private method of LocalProxy here...
    return response._get_current_object()  # type: ignore[attr-defined]
コード例 #3
0
ファイル: utils.py プロジェクト: mazen-hasoun/checkmk
def serve_group(group, serializer):
    response.set_data(json.dumps(serializer(group)))
    if response.status_code != 204:
        response.set_content_type('application/json')
    response.headers.add('ETag', constructors.etag_of_dict(group).to_header())
    return response._get_current_object()
コード例 #4
0
def _serve_host(host):
    response.set_data(json.dumps(serialize_host(host)))
    response.set_content_type('application/json')
    response.headers.add('ETag', constructors.etag_of_obj(host).to_header())
    return response._get_current_object()
コード例 #5
0
ファイル: constructors.py プロジェクト: mazen-hasoun/checkmk
def sucess(status=200):
    response.status_code = status
    # TODO: Why don't we just return response? We access a private method of LocalProxy here...
    return response._get_current_object()  # type: ignore[attr-defined]
コード例 #6
0
def sucess(status=200):
    response.status_code = status
    return response._get_current_object()