Class DataHandlers

Class Documentation

class DataHandlers

Unified HTTP handlers for data operations across all SOVD entity types.

This class provides entity-agnostic handlers for /data endpoints. Works for: /areas/{id}/data, /components/{id}/data, /apps/{id}/data, /functions/{id}/data

Key design decisions:

  • Single handler implementation shared across all entity types

  • Entity type resolved from URL regex match or inferred from entity ID

  • Data aggregated from entity hierarchy (e.g., component includes apps’ topics)

Public Functions

inline explicit DataHandlers(HandlerContext &ctx)
void handle_list_data(const httplib::Request &req, httplib::Response &res)

List all data items (topics) for an entity.

GET /{entities}/{id}/data

URL matches:

  • matches[1]: entity_id

Returns SOVD ValueMetadata items with x-medkit ROS2-specific extensions.

void handle_get_data_item(const httplib::Request &req, httplib::Response &res)

Get a single data item (topic value) for an entity.

GET /{entities}/{id}/data/{topic}

URL matches:

  • matches[1]: entity_id

  • matches[2]: topic_id (may be URL-encoded with slashes)

Returns SOVD ReadValue with current topic data and type_info schema.

void handle_put_data_item(const httplib::Request &req, httplib::Response &res)

Write data to a topic (publish)

PUT /{entities}/{id}/data/{topic}

URL matches:

  • matches[1]: entity_id

  • matches[2]: topic_id (may be URL-encoded with slashes)

Request body: { “type”: “pkg/msg/Type”, “data”: {…} } Returns SOVD WriteValue with echoed data.

void handle_data_categories(const httplib::Request &req, httplib::Response &res)

List data categories (not implemented for ROS 2)

GET /{entities}/{id}/data-categories

Returns 501 Not Implemented.

void handle_data_groups(const httplib::Request &req, httplib::Response &res)

List data groups (not implemented for ROS 2)

GET /{entities}/{id}/data-groups

Returns 501 Not Implemented.