Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/api/server.py
# Copyright (C) 2015-2019 The Software Heritage developers | # Copyright (C) 2015-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import os | import os | ||||
import aiohttp.web | import aiohttp.web | ||||
from swh.core.config import read as config_read | from swh.core.config import read as config_read | ||||
from swh.core.api.asynchronous import (SWHRemoteAPI, decode_request, | from swh.core.api.asynchronous import (RPCServerApp, decode_request, | ||||
encode_data_server as encode_data) | encode_data_server as encode_data) | ||||
from swh.core.api.serializers import msgpack_loads, SWHJSONDecoder | from swh.core.api.serializers import msgpack_loads, SWHJSONDecoder | ||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from swh.objstorage import get_objstorage | from swh.objstorage import get_objstorage | ||||
from swh.objstorage.objstorage import DEFAULT_LIMIT | from swh.objstorage.objstorage import DEFAULT_LIMIT | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | async def list_content(request): | ||||
return response | return response | ||||
def make_app(config): | def make_app(config): | ||||
"""Initialize the remote api application. | """Initialize the remote api application. | ||||
""" | """ | ||||
client_max_size = config.get('client_max_size', 1024 * 1024 * 1024) | client_max_size = config.get('client_max_size', 1024 * 1024 * 1024) | ||||
app = SWHRemoteAPI(client_max_size=client_max_size) | app = RPCServerApp(client_max_size=client_max_size) | ||||
# retro compatibility configuration settings | # retro compatibility configuration settings | ||||
app['config'] = config | app['config'] = config | ||||
_cfg = config['objstorage'] | _cfg = config['objstorage'] | ||||
app['objstorage'] = get_objstorage(_cfg['cls'], _cfg['args']) | app['objstorage'] = get_objstorage(_cfg['cls'], _cfg['args']) | ||||
app.router.add_route('GET', '/', index) | app.router.add_route('GET', '/', index) | ||||
app.router.add_route('POST', '/check_config', check_config) | app.router.add_route('POST', '/check_config', check_config) | ||||
app.router.add_route('POST', '/content/contains', contains) | app.router.add_route('POST', '/content/contains', contains) | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |