Add X-OpenPLC-Runtime-Version header to all API responses

This adds an after_request hook to the REST API blueprint that includes
the X-OpenPLC-Runtime-Version header with value 'v3' in all API responses.

This enables the OpenPLC Editor to detect which runtime version it is
connecting to and show an error if there is a version mismatch between
the selected target and the actual runtime.

Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
This commit is contained in:
Devin AI
2025-12-17 22:44:22 +00:00
parent 23a74f5e3a
commit 995fa8cdbd

View File

@@ -28,6 +28,15 @@ logging.basicConfig(
restapi_bp = Blueprint('restapi_blueprint', __name__)
_handler_callback_get: Optional[Callable[[str, dict], dict]] = None
_handler_callback_post: Optional[Callable[[str, dict], dict]] = None
@restapi_bp.after_request
def add_runtime_version_header(response):
"""Add runtime version header to all API responses for version detection."""
response.headers['X-OpenPLC-Runtime-Version'] = 'v3'
return response
jwt = JWTManager(app_restapi)
db = SQLAlchemy(app_restapi)