Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::HealthController Class Reference

Handles health and info endpoints. More...

#include <mitkHealthController.h>

Public Types

using UptimeCallback = std::function< std::optional< int64_t >()>
 Callback type for retrieving server uptime. More...
 

Public Member Functions

 HealthController (DataStorageBridge &bridge)
 Construct a HealthController. More...
 
void SetUptimeCallback (UptimeCallback callback)
 Set the callback for retrieving server uptime. More...
 
void HandleGET_health (const httplib::Request &req, httplib::Response &res)
 Handle GET /health request. More...
 
void HandleGET_info (const httplib::Request &req, httplib::Response &res)
 Handle GET /info request. More...
 
void HandleGET_config_file_access (const httplib::Request &req, httplib::Response &res)
 Handle GET /config/file-access request. More...
 
void SetFileAccessConfig (FileAccessMode mode, const std::vector< std::string > &allowedDirs)
 Set the file access configuration. More...
 
void SetMaxActiveTempDirsPerIp (size_t max)
 Set the per-IP limit for concurrent file-reference temp directories. Reported by GET /config/file-access so clients know the eviction policy. More...
 

Detailed Description

Handles health and info endpoints.

Endpoints:

  • GET /api/v1/health -> {"status": "ok"}
  • GET /api/v1/info -> Server info including datastorage availability

Definition at line 37 of file mitkHealthController.h.

Member Typedef Documentation

◆ UptimeCallback

using mitk::HealthController::UptimeCallback = std::function<std::optional<int64_t>()>

Callback type for retrieving server uptime.

Returns the server uptime in seconds, or std::nullopt if not available.

Definition at line 45 of file mitkHealthController.h.

Constructor & Destructor Documentation

◆ HealthController()

mitk::HealthController::HealthController ( DataStorageBridge &  bridge)
explicit

Construct a HealthController.

Parameters
bridgeReference to the DataStorageBridge for status checks. It is the instance controlled by the REST server to ensure requests from all controllers are handled thread safe and channeled towards the DataStorage.

Member Function Documentation

◆ HandleGET_config_file_access()

void mitk::HealthController::HandleGET_config_file_access ( const httplib::Request &  req,
httplib::Response &  res 
)

Handle GET /config/file-access request.

Returns the current file access configuration, including the mode and, when restrictions are active, the list of allowed directories.

Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ HandleGET_health()

void mitk::HealthController::HandleGET_health ( const httplib::Request &  req,
httplib::Response &  res 
)

Handle GET /health request.

Returns basic health status.

Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ HandleGET_info()

void mitk::HealthController::HandleGET_info ( const httplib::Request &  req,
httplib::Response &  res 
)

Handle GET /info request.

Returns detailed server information.

Parameters
reqThe HTTP request.
resThe HTTP response to populate.

◆ SetFileAccessConfig()

void mitk::HealthController::SetFileAccessConfig ( FileAccessMode  mode,
const std::vector< std::string > &  allowedDirs 
)

Set the file access configuration.

Precondition
mode must be a valid FileAccessMode value.
When mode is AllowedDirectories, allowedDirs must not be empty.
Parameters
modeThe file access mode to apply.
allowedDirsDirectories to allow when mode is AllowedDirectories.

◆ SetMaxActiveTempDirsPerIp()

void mitk::HealthController::SetMaxActiveTempDirsPerIp ( size_t  max)

Set the per-IP limit for concurrent file-reference temp directories. Reported by GET /config/file-access so clients know the eviction policy.

Precondition
max >= 1.

◆ SetUptimeCallback()

void mitk::HealthController::SetUptimeCallback ( UptimeCallback  callback)

Set the callback for retrieving server uptime.

Parameters
callbackFunction that returns uptime in seconds, or std::nullopt if unavailable.

The documentation for this class was generated from the following file: