Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkHealthController.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkHealthController_h
14 #define mitkHealthController_h
15 
16 #include <mitkDataStorageBridge.h>
17 #include <mitkRestServerConfig.h>
18 #include <httplib.h>
19 
20 #include <MitkRESTAPIExports.h>
21 
22 #include <functional>
23 #include <optional>
24 #include <cstdint>
25 #include <string>
26 #include <vector>
27 
28 namespace mitk
29 {
38  {
39  public:
45  using UptimeCallback = std::function<std::optional<int64_t>()>;
46 
55 
62 
71  void HandleGET_health(const httplib::Request& req, httplib::Response& res);
72 
81  void HandleGET_info(const httplib::Request& req, httplib::Response& res);
82 
92  void HandleGET_config_file_access(const httplib::Request& req, httplib::Response& res);
93 
103  void SetFileAccessConfig(FileAccessMode mode, const std::vector<std::string>& allowedDirs);
104 
110  void SetMaxActiveTempDirsPerIp(size_t max);
111 
112  private:
113  DataStorageBridge& m_Bridge;
114  mutable std::mutex m_Mutex;
115  UptimeCallback m_UptimeCallback;
116  FileAccessMode m_FileAccessMode = FileAccessMode::Unrestricted;
117  std::vector<std::string> m_AllowedFileDirectories;
118  size_t m_MaxActiveTempDirsPerIp = 5;
119  };
120 }
121 
122 #endif
#define MITKRESTAPI_EXPORT
Thread-safe bridge between the REST API layer and MITK DataStorage.
Handles health and info endpoints.
std::function< std::optional< int64_t >()> UptimeCallback
Callback type for retrieving server uptime.
void HandleGET_config_file_access(const httplib::Request &req, httplib::Response &res)
Handle GET /config/file-access request.
void HandleGET_health(const httplib::Request &req, httplib::Response &res)
Handle GET /health request.
void SetUptimeCallback(UptimeCallback callback)
Set the callback for retrieving server uptime.
HealthController(DataStorageBridge &bridge)
Construct a HealthController.
void HandleGET_info(const httplib::Request &req, httplib::Response &res)
Handle GET /info request.
void SetFileAccessConfig(FileAccessMode mode, const std::vector< std::string > &allowedDirs)
Set the file access configuration.
void SetMaxActiveTempDirsPerIp(size_t max)
Set the per-IP limit for concurrent file-reference temp directories. Reported by GET /config/file-acc...
Find image slices visible on a given plane.
FileAccessMode
Access mode for file system path restrictions.
@ Unrestricted
No file path restrictions (default).