-
Notifications
You must be signed in to change notification settings - Fork 97
Include apiVersion
into node/version
endpoint
#6757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Updated the `NodeVersionResponse` struct to include a new `apiVersion` field and adjusted the `version` endpoint to return this additional information. Added `serde` attribute for consistent JSON formatting. - Bumped the package version in Cargo files to 3.10.0. Closes #6697
📝 WalkthroughWalkthroughThis pull request updates the REST API package version from 3.9.1 to 3.10.0 and enhances the Changes
Assessment against linked issues
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
hoprd/rest-api/src/node.rs (1)
46-47
: Consider using a static string for better performance.Since the API version is constant, consider using a static string to avoid allocations on every request:
- let api_version = env!("CARGO_PKG_VERSION").to_owned(); + static API_VERSION: &str = env!("CARGO_PKG_VERSION"); + let api_version = API_VERSION.to_owned();Or even better, make the entire response static:
+ static VERSION_RESPONSE: std::sync::OnceLock<NodeVersionResponse> = std::sync::OnceLock::new(); + let version = state.hopr.version(); - let api_version = env!("CARGO_PKG_VERSION").to_owned(); - (StatusCode::OK, Json(NodeVersionResponse { version, api_version })).into_response() + let response = VERSION_RESPONSE.get_or_init(|| NodeVersionResponse { + version: version.clone(), + api_version: env!("CARGO_PKG_VERSION").to_owned(), + }); + (StatusCode::OK, Json(response)).into_response()
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
📒 Files selected for processing (1)
hoprd/rest-api/src/node.rs
(2 hunks)
🔇 Additional comments (2)
hoprd/rest-api/src/node.rs (2)
24-24
: LGTM! The struct changes look good.The addition of the
api_version
field and the camelCase serialization attribute aligns with the PR objectives and ensures consistent JSON formatting.Also applies to: 27-27
46-46
: Implementation approved despite previous concerns.While there was a discussion about the necessity of this field (see past review comments), the implementation using
CARGO_PKG_VERSION
is appropriate as it aligns with the agreed-upon solution in issue #6697.
NodeVersionResponse
struct to include a newapiVersion
field and adjusted theversion
endpoint to return this additional information. Addedserde
attribute for consistent JSON formatting.Closes #6697