1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #4173: Return graceful error message when webhook queuing fails

This commit is contained in:
Jeremy Stretch
2020-02-21 17:21:04 -05:00
parent 12602a95ea
commit 9128dc961c
4 changed files with 29 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ from django.db import ProgrammingError
from django.http import Http404, HttpResponseRedirect
from django.urls import reverse
from .api import is_api_request
from .views import server_error
@@ -38,9 +39,8 @@ class APIVersionMiddleware(object):
self.get_response = get_response
def __call__(self, request):
api_path = reverse('api-root')
response = self.get_response(request)
if request.path_info.startswith(api_path):
if is_api_request(request):
response['API-Version'] = settings.REST_FRAMEWORK_VERSION
return response