Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkIRestServerService.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 mitkIRestServerService_h
14 #define mitkIRestServerService_h
15 
16 #include <mitkServiceInterface.h>
17 #include <mitkRestServerConfig.h>
18 #include <mitkDataStorage.h>
19 
20 namespace mitk { class RenderWindowBridge; }
21 
22 #include <string>
23 #include <optional>
24 #include <vector>
25 #include <cstdint>
26 
27 #include <MitkRESTAPIExports.h>
28 
29 namespace mitk
30 {
35  {
36  std::string endpoint;
37  std::string method;
39  std::string clientIP;
40  };
41 
64  {
66 
67  // Lifecycle
68 
82  virtual bool Start() = 0;
83 
89  virtual void Stop() = 0;
90 
95  virtual bool IsRunning() const = 0;
96 
97  // Configuration
98 
108  virtual void SetConfig(const RestServerConfig& config) = 0;
109 
117  virtual RestServerConfig GetPendingConfig() const = 0;
118 
124  virtual std::optional<RestServerConfig> GetRunningConfig() const = 0;
125 
126  // Render-window integration
127 
139 
140  // DataStorage connection
141 
151  virtual void SetDataStorage(DataStorage* dataStorage) = 0;
152 
157  virtual DataStorage::Pointer GetDataStorage() const = 0;
158 
159  // Status
160 
166  virtual std::optional<std::string> GetServerUrl() const = 0;
167 
173  virtual std::optional<std::string> GetLastError() const = 0;
174 
175  // Request tracking
176 
185  virtual std::vector<std::string> GetClientIPs() const = 0;
186 
192  virtual std::optional<RequestInfo> GetLastRequestInfo() const = 0;
193 
202  virtual void SetLogLimit(std::optional<unsigned int> limit) = 0;
203 
209  virtual std::optional<unsigned int> GetLogLimit() const = 0;
210 
218  virtual std::vector<RequestInfo> GetRequestLog() const = 0;
219 
223  virtual void ClearRequestLog() = 0;
224 
233  virtual uint64_t GetRequestLogVersion() const = 0;
234 
240  virtual std::optional<int64_t> GetUptimeSeconds() const = 0;
241  };
242 }
243 
244 MITK_DECLARE_SERVICE_INTERFACE(mitk::IRestServerService, "org.mitk.IRestServerService")
245 
246 #endif
#define MITKRESTAPI_EXPORT
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Bridge between the REST API server and the Qt/render-window layer.
Provides the MITK_DECLARE_SERVICE_INTERFACE macro for registering C++ interfaces with both the CppMic...
#define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId)
Declare a C++ interface for use with CppMicroServices (Qt not available).
Find image slices visible on a given plane.
Service interface for the REST API server.
virtual RestServerConfig GetPendingConfig() const =0
Get the pending server configuration.
virtual bool IsRunning() const =0
Check if the server is currently running.
virtual DataStorage::Pointer GetDataStorage() const =0
Get the currently connected DataStorage.
virtual std::optional< int64_t > GetUptimeSeconds() const =0
Get the server uptime in seconds.
virtual void SetLogLimit(std::optional< unsigned int > limit)=0
Set the request log limit.
virtual RenderWindowBridge * GetRenderWindowBridge()=0
Return the server-owned RenderWindowBridge.
virtual void Stop()=0
Stop the REST server.
virtual std::optional< std::string > GetLastError() const =0
Get the last error message.
virtual void SetDataStorage(DataStorage *dataStorage)=0
Set the DataStorage for REST API operations.
virtual std::vector< std::string > GetClientIPs() const =0
Get the list of client IP addresses that have sent requests.
virtual uint64_t GetRequestLogVersion() const =0
Get the request log version counter.
virtual void SetConfig(const RestServerConfig &config)=0
Set the pending server configuration.
virtual std::optional< RestServerConfig > GetRunningConfig() const =0
Get the configuration the server is currently running with.
virtual std::vector< RequestInfo > GetRequestLog() const =0
Get all logged requests.
virtual void ClearRequestLog()=0
Clear all logged requests.
virtual std::optional< unsigned int > GetLogLimit() const =0
Get the current request log limit.
virtual bool Start()=0
Start the REST server with the pending configuration.
virtual std::optional< RequestInfo > GetLastRequestInfo() const =0
Get information about the last request processed.
virtual std::optional< std::string > GetServerUrl() const =0
Get the full URL where the server is listening.
Information about a REST API request.
int responseCode
HTTP response code (200, 404, 500, etc.)
std::string method
HTTP method (GET, POST, PUT, DELETE)
std::string endpoint
The endpoint path (e.g., "/nodes", "/nodes/123")
std::string clientIP
IP address of the client.
Configuration parameters for the REST API server.