Add X-OpenPLC-Runtime-Version header to all API responses#50
Conversation
This adds an after_request hook to the REST API blueprint that includes the X-OpenPLC-Runtime-Version header with value 'v4' 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>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Pull request overview
This PR adds version detection capability to the OpenPLC v4 runtime API by injecting an X-OpenPLC-Runtime-Version: v4 header into all API responses. This allows the OpenPLC Editor to verify it's connecting to the correct runtime version and alert users about version mismatches. The change also includes automated code cleanup from pre-commit hooks, including import reordering, removal of an unused LogParser import, removal of an unused exception variable, and code formatting adjustments.
Key changes:
- Added
after_requesthook to inject version header into all API responses - Removed unused imports and variables flagged by pre-commit tools
- Minor formatting improvements to existing code
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Adds an
after_requesthook to the REST API blueprint that includes theX-OpenPLC-Runtime-Versionheader with valuev4in 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 (v3 vs v4) and the actual runtime.This is part of a coordinated change across three repositories:
v3header (PR Rtop 70 implement command logs #7)v4headerThe diff also includes minor cleanup from pre-commit hooks: removed unused
LogParserimport, removed unused exception variablee, and import reordering.Review & Testing Checklist for Human
X-OpenPLC-Runtime-Version: v4appears on API responses by running the runtime and testing with curl:LogParserimport and unusedevariable) doesn't affect any other code pathsNotes