Skip to content

Commit

Permalink
Added X-Server to all responses
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmwatson committed Dec 12, 2024
1 parent b04dbdc commit 6b62499
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pombola/middleware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from instances.models import Instance
import socket
from django.utils.deprecation import MiddlewareMixin

class FakeInstanceMiddleware:
"""
Expand All @@ -12,3 +14,10 @@ def process_request(self, request):
# speeches to any users of the site at the moment, so force
# that no user of the site is regarded as its owner.
request.is_user_instance = False

# Which server behind load balancer served the request
class AddServerDetailsMiddleware(MiddlewareMixin):
def process_response(self, request, response):
server_hostname = socket.gethostname()
response['X-Server'] = server_hostname
return response
1 change: 1 addition & 0 deletions pombola/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"pagination.middleware.PaginationMiddleware",
"mapit.middleware.ViewExceptionMiddleware",
"django.middleware.security.SecurityMiddleware",
"pombola.middleware.AddServerDetailsMiddleware",
)

CORS_ALLOW_HEADERS = default_headers + ("HTTP_AUTHORIZATION", "SENTRY-TRACE")
Expand Down

0 comments on commit 6b62499

Please sign in to comment.