mirror of
https://github.com/thiagoralves/OpenPLC_v3.git
synced 2026-02-06 02:02:20 +08:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user