PR https://github.com/chibisov/drf-extensions/pull/171 introduces a new generic decorator @precondition_required. It enables the check for a set of preconditions (i.e. required HTTP headers). If the precondition is not met, a 428 PRECONDITION REQUIRED exception will be raised, rendered as rest_framework.exceptions.APIException to API clients.
Optimistic concurrency control (OCC) has been implemented using ETags to identify the 'version' of an API resource. It combines the existing @etag decorator and @precondition_required to enforce the header check in OCC.
The @precondition_required decorator is versatile and can be used to check for custom request headers. Such a header is used in bulk-processing in drf-extensions, so refactoring using the new decorator seems possible.
PR https://github.com/chibisov/drf-extensions/pull/171 introduces a new generic decorator
@precondition_required
. It enables the check for a set of preconditions (i.e. required HTTP headers). If the precondition is not met, a428 PRECONDITION REQUIRED
exception will be raised, rendered asrest_framework.exceptions.APIException
to API clients.Optimistic concurrency control (OCC) has been implemented using
ETag
s to identify the 'version' of an API resource. It combines the existing@etag
decorator and@precondition_required
to enforce the header check in OCC.The
@precondition_required
decorator is versatile and can be used to check for custom request headers. Such a header is used in bulk-processing indrf-extensions
, so refactoring using the new decorator seems possible.