According to REST design guidelines it is better to map state changing actions like activate
, publish
, share
to PUT methods body as fields.
Like that:
PUT /api/articles/32
{
"activated": true
}
My question is how to dispatch in put method handler in the backend which action is which. How do i know if it is "activated" or it is "shared"? Any suggestions?
@detail_route(methods=['PUT'])
def put(self, request, *args, **kwargs):
# if action == 'activate'
# activate()
# if action == 'publish'
# publish()
return Response(status=status.HTTP_200_OK)