def add_product(self, request):
""" Add product to cache in every region
This endpoint can be called in any region and will dispatch event
which will be handled by indexer's `handle_product_added`
in all regions
"""
try:
payload = Product(strict=True).loads(
request.get_data(as_text=True)
).data
except ValidationError as err:
return 400, json.dumps({
'error': 'BAD_REQUEST',
'message': err.messages
})
self.dispatch('product_added', Product(strict=True).dump(payload).data)
return 200, ''
评论列表
文章目录