Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
mitk::RESTManager Class Reference

this is a microservice for managing REST-requests, used for non-qt applications. More...

#include <mitkRESTManager.h>

Inheritance diagram for mitk::RESTManager:
Collaboration diagram for mitk::RESTManager:

Public Member Functions

 RESTManager ()
 
 ~RESTManager () override
 
pplx::task< web::json::value > SendRequest (const web::uri &uri, const RequestType &type=RequestType::Get, const std::map< utility::string_t, utility::string_t > headers={}) override
 Executes a HTTP request in the mitkRESTClient class. More...
 
pplx::task< web::json::value > SendJSONRequest (const web::uri &uri, const RequestType &type=RequestType::Get, const web::json::value *body=nullptr, const std::map< utility::string_t, utility::string_t > headers={}, const utility::string_t &filePath={}) override
 Executes a HTTP request in the mitkRESTClient class. More...
 
pplx::task< web::json::value > SendBinaryRequest (const web::uri &uri, const RequestType &type=RequestType::Get, const std::vector< unsigned char > *body={}, const std::map< utility::string_t, utility::string_t > headers={}) override
 Executes a HTTP request in the mitkRESTClient class. More...
 
void ReceiveRequest (const web::uri &uri, IRESTObserver *observer) override
 starts listening for requests if there isn't another observer listening and the port is free More...
 
web::http::http_response Handle (const web::uri &uri, const web::json::value &body, const web::http::method &method, const mitk::RESTUtil::ParamMap &headers) override
 Handles incoming requests by notifying the observer which should receive it. More...
 
void HandleDeleteObserver (IRESTObserver *observer, const web::uri &uri={}) override
 Handles the deletion of an observer for all or a specific uri. More...
 
const std::map< int, RESTServer * > & GetServerMap () override
 internal use only More...
 
std::map< std::pair< int, utility::string_t >, IRESTObserver * > & GetObservers () override
 
- Public Member Functions inherited from mitk::IRESTManager
virtual ~IRESTManager ()
 

Additional Inherited Members

- Public Types inherited from mitk::IRESTManager
enum  RequestType { RequestType::Get, RequestType::Post, RequestType::Put }
 request type for client requests by calling SendRequest More...
 

Detailed Description

this is a microservice for managing REST-requests, used for non-qt applications.

RESTManagerQt in the CppRestSdkQt module inherits from this class and is the equivalent microservice used for Qt applications.

Definition at line 29 of file mitkRESTManager.h.

Constructor & Destructor Documentation

◆ RESTManager()

mitk::RESTManager::RESTManager ( )

◆ ~RESTManager()

mitk::RESTManager::~RESTManager ( )
override

Member Function Documentation

◆ GetObservers()

std::map<std::pair<int, utility::string_t>, IRESTObserver *>& mitk::RESTManager::GetObservers ( )
overridevirtual

Implements mitk::IRESTManager.

◆ GetServerMap()

const std::map<int, RESTServer *>& mitk::RESTManager::GetServerMap ( )
overridevirtual

internal use only

Implements mitk::IRESTManager.

◆ Handle()

web::http::http_response mitk::RESTManager::Handle ( const web::uri &  uri,
const web::json::value &  body,
const web::http::method &  method,
const mitk::RESTUtil::ParamMap headers 
)
overridevirtual

Handles incoming requests by notifying the observer which should receive it.

Parameters
uridefines the URI of the request
bodythe body of the request
methodthe http method of the request
headersthe http headers of the request
Returns
the response

Implements mitk::IRESTManager.

◆ HandleDeleteObserver()

void mitk::RESTManager::HandleDeleteObserver ( IRESTObserver observer,
const web::uri &  uri = {} 
)
overridevirtual

Handles the deletion of an observer for all or a specific uri.

Parameters
observerthe observer which shouldn't receive requests anymore
urithe uri for which the observer doesn't handle requests anymore (optional)

Implements mitk::IRESTManager.

◆ ReceiveRequest()

void mitk::RESTManager::ReceiveRequest ( const web::uri &  uri,
IRESTObserver observer 
)
overridevirtual

starts listening for requests if there isn't another observer listening and the port is free

Parameters
uridefines the URI for which incoming requests should be send to the observer
observerthe observer which handles the incoming requests

Implements mitk::IRESTManager.

◆ SendBinaryRequest()

pplx::task<web::json::value> mitk::RESTManager::SendBinaryRequest ( const web::uri &  uri,
const RequestType type = RequestType::Get,
const std::vector< unsigned char > *  body = {},
const std::map< utility::string_t, utility::string_t >  headers = {} 
)
overridevirtual

Executes a HTTP request in the mitkRESTClient class.

Exceptions
mitk::Exceptionif RequestType is not suported
Parameters
uridefines the URI the request is send to
typethe RequestType of the HTTP request (optional)
bodythe body for the request (optional)
headersthe headers for the request (optional)
Returns
task to wait for

Implements mitk::IRESTManager.

◆ SendJSONRequest()

pplx::task<web::json::value> mitk::RESTManager::SendJSONRequest ( const web::uri &  uri,
const RequestType type = RequestType::Get,
const web::json::value *  body = nullptr,
const std::map< utility::string_t, utility::string_t >  headers = {},
const utility::string_t &  filePath = {} 
)
overridevirtual

Executes a HTTP request in the mitkRESTClient class.

Exceptions
mitk::Exceptionif RequestType is not suported
Parameters
uridefines the URI the request is send to
typethe RequestType of the HTTP request (optional)
bodythe body for the request (optional)
headersthe headers for the request (optional)
filePaththe file path to store the request to (optional)
Returns
task to wait for

Implements mitk::IRESTManager.

◆ SendRequest()

pplx::task<web::json::value> mitk::RESTManager::SendRequest ( const web::uri &  uri,
const RequestType type = RequestType::Get,
const std::map< utility::string_t, utility::string_t >  headers = {} 
)
overridevirtual

Executes a HTTP request in the mitkRESTClient class.

Exceptions
mitk::Exceptionif RequestType is not suported
Parameters
uridefines the URI the request is send to
typethe RequestType of the HTTP request (optional)
headersthe headers for the request (optional)
Returns
task to wait for

Implements mitk::IRESTManager.


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