-
Notifications
You must be signed in to change notification settings - Fork 2
[#40] fix: return server capabilities at GET / and add GET /version-info #42
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
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.
Pull request overview
This PR refactors the gateway's root endpoint to provide server capabilities discovery (REQ_INTEROP_010) and adds a new /version-info endpoint for version information (REQ_INTEROP_001). The changes improve API discoverability by clearly separating concerns: the root endpoint now serves as a capabilities and endpoints directory, while the new endpoint provides runtime version and status information.
- Modified GET / to return server capabilities (name, version, endpoints list, capabilities object) instead of just status and version
- Added GET /version-info endpoint to provide status, version, and timestamp information
- Updated integration tests to verify both endpoint responses with comprehensive assertions
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ros2_medkit_gateway/src/rest_server.cpp | Refactored handle_root() to return capabilities response; added handle_version_info() for new endpoint |
| src/ros2_medkit_gateway/include/ros2_medkit_gateway/rest_server.hpp | Added handle_version_info() method declaration |
| src/ros2_medkit_gateway/test/test_integration.test.py | Updated test_01_root_endpoint to verify capabilities; added test_01b_version_info_endpoint |
| postman/collections/ros2-medkit-gateway.postman_collection.json | Renamed "GET Gateway Info" to "GET Server Capabilities"; added "GET Version Info" request with descriptions |
Comments suppressed due to low confidence (1)
src/ros2_medkit_gateway/src/rest_server.cpp:204
- The version string "0.1.0" is hardcoded in two places (lines 171 and 204). Consider extracting this to a constant or reading from package.xml to maintain consistency and simplify version management. This would prevent version mismatches between the package.xml and the API responses.
{"version", "0.1.0"},
{"endpoints", json::array({
"/health",
"/version-info",
"/areas",
"/components",
"/areas/{area_id}/components",
"/components/{component_id}/data",
"/components/{component_id}/data/{topic_name}"
})},
{"capabilities", {
{"discovery", true},
{"data_access", true}
}}
};
res.set_content(response.dump(2), "application/json");
} catch (const std::exception& e) {
res.status = StatusCode::InternalServerError_500;
res.set_content(
json{{"error", "Internal server error"}}.dump(),
"application/json"
);
RCLCPP_ERROR(rclcpp::get_logger("rest_server"), "Error in handle_root: %s", e.what());
}
}
void RESTServer::handle_version_info(const httplib::Request& req, httplib::Response& res) {
(void)req; // Unused parameter
try {
json response = {
{"status", "ROS 2 Medkit Gateway running"},
{"version", "0.1.0"},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bb5bfc1 to
16201cf
Compare
bburda
left a comment
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.
LGTM
- GET / now returns server capabilities and entry points per REQ_INTEROP_010
(name, version, endpoints list, capabilities object)
- Add GET /version-info for version information per REQ_INTEROP_001
(status, version, timestamp)
- Update test_01_root_endpoint to verify capabilities response
- Add test_01b_version_info_endpoint for new endpoint
- Update Postman collection with new requests
16201cf to
9b778c4
Compare
Pull Request
Summary
Briefly describe what changed and why.
Issue
Link the related issue (required):
Type
Testing
How was this tested / how should reviewers verify it?
Checklist