Skip to content

Commit

Permalink
Added new idempotent replayed header
Browse files Browse the repository at this point in the history
  • Loading branch information
OdinsPlasmaRifle committed Dec 11, 2020
1 parent 882c65a commit e7577c6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
28 changes: 28 additions & 0 deletions drf_request_logging/migrations/0005_auto_20201211_1549.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.1.2 on 2020-12-11 15:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('drf_request_logging', '0004_auto_20200821_1433'),
]

operations = [
migrations.AlterField(
model_name='request',
name='body',
field=models.JSONField(blank=True, default=dict, null=True),
),
migrations.AlterField(
model_name='request',
name='headers',
field=models.JSONField(blank=True, default=dict, null=True),
),
migrations.AlterField(
model_name='request',
name='params',
field=models.JSONField(blank=True, default=dict, null=True),
),
]
2 changes: 2 additions & 0 deletions drf_request_logging/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def finalize_response(self, request, response, *args, **kwargs):
if self.old_request:
# Update the "updated" date on the request.
self.old_request.save()
# Set the idempotent replayed header to true.
response["Idempotent-Replayed"] = "true"
# This request belongs to a specific user.
elif user:
# This request was not previously saved because it was an
Expand Down
7 changes: 3 additions & 4 deletions drf_request_logging/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pickle

from django.db import models
from django.contrib.postgres.fields import JSONField
from django.conf import settings
from enumfields import EnumField

Expand Down Expand Up @@ -39,9 +38,9 @@ class Request(models.Model):
method = models.CharField(db_index=True, max_length=10)
encoding = models.CharField(null=True, blank=True, max_length=100)
content_type = models.CharField(max_length=100)
params = JSONField(null=True, blank=True, default=dict)
headers = JSONField(null=True, blank=True, default=dict)
body = JSONField(null=True, blank=True, default=dict)
params = models.JSONField(null=True, blank=True, default=dict)
headers = models.JSONField(null=True, blank=True, default=dict)
body = models.JSONField(null=True, blank=True, default=dict)
status_code = models.IntegerField(db_index=True, null=True, blank=True)
# The binary response data (pickled).
response = models.BinaryField(null=True, blank=True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import find_packages, setup


VERSION = '0.0.11'
VERSION = '0.0.12'

with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
README = readme.read()
Expand Down

0 comments on commit e7577c6

Please sign in to comment.