simplified the controller code to make use of the new request headers object
This commit is contained in:
parent
5c2a29a21a
commit
e835a99b43
|
@ -70,9 +70,9 @@
|
||||||
<th>Content</th>
|
<th>Content</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="header in request.headers">
|
<tr v-for="(value, header) in request.headers">
|
||||||
<td>[[header.name]]</td>
|
<td>[[header]]</td>
|
||||||
<td>[[header.value]]</td>
|
<td>[[value]]</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -51,17 +51,10 @@ class CallbackView(View):
|
||||||
"ip_address": get_ip_address(request),
|
"ip_address": get_ip_address(request),
|
||||||
"query_params": request.GET,
|
"query_params": request.GET,
|
||||||
"body": body,
|
"body": body,
|
||||||
"headers": self._received_headers(),
|
"headers": self._filter_headers(request.headers),
|
||||||
"received_at": timezone.now().isoformat(),
|
"received_at": timezone.now().isoformat(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _received_headers(self):
|
def _filter_headers(self, headers):
|
||||||
request = self.request
|
exc = settings.EXCLUDED_HEADERS
|
||||||
headers = []
|
return {key: value for key, value in headers.items() if key not in exc}
|
||||||
for key, value in request.META.items():
|
|
||||||
if key.startswith("HTTP") and key not in settings.EXCLUDED_HEADERS:
|
|
||||||
original_header = (
|
|
||||||
key.replace("HTTP_", "").replace("_", "-").capitalize()
|
|
||||||
)
|
|
||||||
headers.append({"name": original_header, "value": value})
|
|
||||||
return headers
|
|
||||||
|
|
|
@ -116,4 +116,4 @@ CHANNEL_LAYERS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Should use the format of request.META
|
# Should use the format of request.META
|
||||||
EXCLUDED_HEADERS = os.environ.get("EXCLUDE_HEADERS", "").split(",")
|
EXCLUDED_HEADERS = os.environ.get("EXCLUDED_HEADERS", "").split(",")
|
||||||
|
|
Loading…
Reference in New Issue