Class LockHandlers
Defined in File lock_handlers.hpp
Class Documentation
-
class LockHandlers
Handlers for SOVD entity locking REST API endpoints.
Provides handlers for:
POST /{entity_type}/{entity_id}/locks - Acquire lock
GET /{entity_type}/{entity_id}/locks - List locks
GET /{entity_type}/{entity_id}/locks/{lock_id} - Get lock
PUT /{entity_type}/{entity_id}/locks/{lock_id} - Extend lock
DELETE /{entity_type}/{entity_id}/locks/{lock_id} - Release lock
Locking is supported for components and apps only (per SOVD spec).
Public Functions
-
LockHandlers(HandlerContext &ctx, LockManager *lock_manager)
Construct lock handlers with shared context and lock manager.
- Parameters:
ctx – The shared handler context
lock_manager – Pointer to the LockManager (may be nullptr if locking disabled)
-
void handle_acquire_lock(const httplib::Request &req, httplib::Response &res)
Handle POST /{entity_type}/{entity_id}/locks - acquire a lock.
Request body: {“scopes”: […], “lock_expiration”: 300, “break_lock”: false} Requires X-Client-Id header. Returns 201 with lock info on success.
-
void handle_list_locks(const httplib::Request &req, httplib::Response &res)
Handle GET /{entity_type}/{entity_id}/locks - list locks on entity.
X-Client-Id header is optional (used to determine “owned” field). Returns 200 with {“items”: […]}.
-
void handle_get_lock(const httplib::Request &req, httplib::Response &res)
Handle GET /{entity_type}/{entity_id}/locks/{lock_id} - get lock details.
X-Client-Id header is optional (used to determine “owned” field). Returns 200 with lock info, or 404 if not found.
-
void handle_extend_lock(const httplib::Request &req, httplib::Response &res)
Handle PUT /{entity_type}/{entity_id}/locks/{lock_id} - extend lock.
Request body: {“lock_expiration”: 300} Requires X-Client-Id header. Returns 204 on success, 403 if not owner, 404 if not found.
-
void handle_release_lock(const httplib::Request &req, httplib::Response &res)
Handle DELETE /{entity_type}/{entity_id}/locks/{lock_id} - release lock.
Requires X-Client-Id header. Returns 204 on success, 403 if not owner, 404 if not found.