2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-03-30 08:01:07 +00:00

feat(backend): add inventree version to every response (#11611)

* feat(backend): add inventree version to every response

* add more info
This commit is contained in:
Matthias Mair
2026-03-29 05:27:05 +02:00
committed by GitHub
parent 7614973a04
commit e3c9a35bae
2 changed files with 18 additions and 0 deletions

View File

@@ -19,6 +19,11 @@ from error_report.middleware import ExceptionProcessor
from common.settings import get_global_setting
from InvenTree.cache import create_session_cache, delete_session_cache
from InvenTree.config import CONFIG_LOOKUPS, inventreeInstaller
from InvenTree.version import (
inventreeApiVersion,
inventreePythonVersion,
inventreeVersion,
)
from users.models import ApiToken
logger = structlog.get_logger('inventree')
@@ -393,3 +398,15 @@ class InvenTreeHostSettingsMiddleware(MiddlewareMixin):
# All checks passed
return None
class InvenTreeVersionHeaderMiddleware(MiddlewareMixin):
"""Middleware to add the InvenTree version header to all responses."""
def process_response(self, request, response):
"""Add the InvenTree version header to the response."""
response['X-InvenTree-Version'] = inventreeVersion()
response['X-InvenTree-API'] = inventreeApiVersion()
response['X-InvenTree-Python'] = inventreePythonVersion()
response['X-InvenTree-Installer'] = inventreeInstaller()
return response

View File

@@ -372,6 +372,7 @@ MIDDLEWARE = CONFIG.get(
'InvenTree.middleware.InvenTreeRequestCacheMiddleware', # Request caching
'InvenTree.middleware.InvenTreeHostSettingsMiddleware', # Ensuring correct hosting/security settings
'django_structlog.middlewares.RequestMiddleware', # Structured logging
'InvenTree.middleware.InvenTreeVersionHeaderMiddleware',
],
)