Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/api/server.py
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
@app.route("/content/get_stream/<hex_id>") | @app.route("/content/get_stream/<hex_id>") | ||||
def get_stream(hex_id): | def get_stream(hex_id): | ||||
obj_id = hashutil.hash_to_bytes(hex_id) | obj_id = hashutil.hash_to_bytes(hex_id) | ||||
def generate(): | def generate(): | ||||
with timed_context("get_stream"): | with timed_context("get_stream"): | ||||
yield from objstorage.get_stream(obj_id, 2 << 20) | yield from get_objstorage().get_stream(obj_id, 2 << 20) | ||||
return app.response_class(generate()) | return app.response_class(generate()) | ||||
@app.route("/content") | @app.route("/content") | ||||
def list_content(): | def list_content(): | ||||
last_obj_id = request.args.get("last_obj_id") | last_obj_id = request.args.get("last_obj_id") | ||||
if last_obj_id: | if last_obj_id: | ||||
last_obj_id = bytes.fromhex(last_obj_id) | last_obj_id = bytes.fromhex(last_obj_id) | ||||
limit = int(request.args.get("limit", DEFAULT_LIMIT)) | limit = int(request.args.get("limit", DEFAULT_LIMIT)) | ||||
def generate(): | def generate(): | ||||
yield b"" | |||||
with timed_context("get_stream"): | with timed_context("get_stream"): | ||||
yield from objstorage.list_content(last_obj_id, limit=limit) | yield from get_objstorage().list_content(last_obj_id, limit=limit) | ||||
return app.response_class(generate()) | return app.response_class(generate()) | ||||
api_cfg = None | api_cfg = None | ||||
def load_and_check_config(config_file): | def load_and_check_config(config_file): | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |