Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 > *={}, 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 ( )

Definition at line 21 of file mitkRESTManager.cpp.

◆ ~RESTManager()

mitk::RESTManager::~RESTManager ( )
override

Definition at line 23 of file mitkRESTManager.cpp.

Member Function Documentation

◆ GetObservers()

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

Implements mitk::IRESTManager.

Definition at line 191 of file mitkRESTManager.cpp.

References mitk::ImageMappingHelper::map(), and MITK_ERROR.

◆ GetServerMap()

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

internal use only

Implements mitk::IRESTManager.

Definition at line 186 of file mitkRESTManager.cpp.

◆ 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.

Definition at line 130 of file mitkRESTManager.cpp.

References MITK_WARN.

◆ 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.

Definition at line 151 of file mitkRESTManager.cpp.

◆ ReceiveRequest()

void mitk::RESTManager::ReceiveRequest ( const web::uri &  uri,
mitk::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.

Definition at line 107 of file mitkRESTManager.cpp.

◆ SendBinaryRequest()

pplx::task< web::json::value > mitk::RESTManager::SendBinaryRequest ( const web::uri &  uri,
const RequestType type = RequestType::Get,
const std::vector< unsigned char > *  content = {},
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.

Definition at line 44 of file mitkRESTManager.cpp.

References MITK_WARN, mitkThrow, and mitk::IRESTManager::Post.

◆ 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.

Definition at line 69 of file mitkRESTManager.cpp.

References mitk::IRESTManager::Get, MITK_WARN, mitkThrow, mitk::IRESTManager::Post, and mitk::IRESTManager::Put.

◆ 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.

Definition at line 25 of file mitkRESTManager.cpp.

References mitk::IRESTManager::Get, and mitkThrow.


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