Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkIRESTManager.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 mitkIRESTManager_h
14 #define mitkIRESTManager_h
15 
16 #include <mitkServiceInterface.h>
17 
18 #include <MitkRESTExports.h>
19 #include <mitkRESTUtil.h>
20 
21 #include <cpprest/json.h>
22 #include <cpprest/uri.h>
23 #include <cpprest/http_client.h>
24 
25 namespace mitk
26 {
27  class IRESTObserver;
28  class RESTServer;
29 
34  class MITKREST_EXPORT IRESTManager
35  {
36  public:
37  virtual ~IRESTManager();
38 
42  enum class RequestType
43  {
44  Get,
45  Post,
46  Put
47  };
48 
58  virtual pplx::task<web::json::value> SendRequest(
59  const web::uri &uri,
60  const RequestType &type = RequestType::Get,
61  const std::map<utility::string_t, utility::string_t> headers = {}) = 0;
62 
73  virtual pplx::task<web::json::value> SendJSONRequest(
74  const web::uri &uri,
75  const RequestType &type = RequestType::Get,
76  const web::json::value *body = nullptr,
77  const std::map<utility::string_t, utility::string_t> headers = {},
78  const utility::string_t &filePath = {}
79  ) = 0;
80 
90  virtual pplx::task<web::json::value> SendBinaryRequest(const web::uri &uri,
91  const RequestType &type = RequestType::Get,
92  const std::vector<unsigned char> *body = {},
93  const std::map<utility::string_t, utility::string_t> headers = {}) = 0;
94 
101  virtual void ReceiveRequest(const web::uri &uri, IRESTObserver *observer) = 0;
102 
112  virtual web::http::http_response Handle(const web::uri &uri,
113  const web::json::value &body,
114  const web::http::method &method,
115  const mitk::RESTUtil::ParamMap &headers) = 0;
116 
123  virtual void HandleDeleteObserver(IRESTObserver *observer, const web::uri &uri = {}) = 0;
124 
125  virtual const std::map<int, RESTServer *>& GetServerMap() = 0;
126  virtual const std::map<std::pair<int, utility::string_t>, IRESTObserver *>& GetObservers() = 0;
127 
128  };
129 }
130 
131 MITK_DECLARE_SERVICE_INTERFACE(mitk::IRESTManager, "org.mitk.IRESTManager")
132 
133 #endif
mitk::IRESTManager
This is a microservice interface for managing REST requests.
Definition: mitkIRESTManager.h:34
mitkServiceInterface.h
mitk::RESTUtil::ParamMap
std::map< utility::string_t, utility::string_t > ParamMap
Definition: mitkRESTUtil.h:27
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitkRESTUtil.h
mitk::MitkMultilabelIOMimeTypes::Get
MITKMULTILABELIO_EXPORT std::vector< CustomMimeType * > Get()
mitk::IRESTManager::RequestType
RequestType
request type for client requests by calling SendRequest
Definition: mitkIRESTManager.h:42
MITK_DECLARE_SERVICE_INTERFACE
#define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId)
Definition: mitkServiceInterface.h:26