def bookshelf_new(request):
"""
Add the given book to the shelf event lake.
"""
payload = await request.content.read()
# ensure the book gets an id
book = json.loads(payload.decode('utf-8'))
book["id"] = str(uuid.uuid4())
# create an event from this request
event = make_event(name="book-added",
payload=json.dumps(book),
safe=False, idempotent=False)
# let's push it
await send_event(b"bookshelf", event)
return web.json_response(status=201, data=book)
评论列表
文章目录