httpmockserver
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
httpmock::MockServer Class Referenceabstract

#include <mock_server.h>

Inheritance diagram for httpmock::MockServer:
Inheritance graph
[legend]
Collaboration diagram for httpmock::MockServer:
Collaboration graph
[legend]

Classes

struct  Header
 
struct  KeyValue
 Key-Value storage. More...
 
struct  Response
 Response object. More...
 
class  Server
 
struct  UrlArg
 Url argument (with optional value) More...
 

Public Member Functions

 MockServer (int port=8080)
 Create server instance. Server is not started by default. Use start(). More...
 
virtual ~MockServer ()
 
virtual void start () override
 Starts the server. More...
 
virtual void stop () override
 Stops the server. More...
 
virtual bool isRunning () const override
 Return true if server is running. More...
 
int getPort () const
 Return port number server is running on. More...
 
- Public Member Functions inherited from httpmock::IMockServer
virtual ~IMockServer ()=0
 

Private Member Functions

 MockServer (const MockServer &)
 
MockServeroperator= (const MockServer &)
 
 MockServer (MockServer &&)
 
virtual Response responseHandler (const std::string &url, const std::string &method, const std::string &data, const std::vector< UrlArg > &urlArguments={}, const std::vector< Header > &headers={})=0
 

Private Attributes

std::unique_ptr< Serverserver
 Server implementation. More...
 
int port
 Port to run server on. More...
 

Constructor & Destructor Documentation

◆ MockServer() [1/3]

httpmock::MockServer::MockServer ( const MockServer )
private

◆ MockServer() [2/3]

httpmock::MockServer::MockServer ( MockServer &&  )
private

◆ MockServer() [3/3]

httpmock::MockServer::MockServer ( int  port = 8080)
explicit

Create server instance. Server is not started by default. Use start().

◆ ~MockServer()

httpmock::MockServer::~MockServer ( )
virtual

Member Function Documentation

◆ getPort()

int httpmock::MockServer::getPort ( ) const

Return port number server is running on.

◆ isRunning()

bool httpmock::MockServer::isRunning ( ) const
overridevirtual

Return true if server is running.

Implements httpmock::IMockServer.

◆ operator=()

MockServer& httpmock::MockServer::operator= ( const MockServer )
private

◆ responseHandler()

virtual Response httpmock::MockServer::responseHandler ( const std::string &  url,
const std::string &  method,
const std::string &  data,
const std::vector< UrlArg > &  urlArguments = {},
const std::vector< Header > &  headers = {} 
)
privatepure virtual

HTTP response handler.

Parameters
urlURL path of the request.
methodHTTP method (GET, POST, ...).
dataData received during the request.
urlArgumentsArguments passed in the URL (after ? sign).
headersHeaders of the HTTP request.

◆ start()

void httpmock::MockServer::start ( )
overridevirtual

Starts the server.

Implements httpmock::IMockServer.

◆ stop()

void httpmock::MockServer::stop ( )
overridevirtual

Stops the server.

Implements httpmock::IMockServer.

Member Data Documentation

◆ port

int httpmock::MockServer::port
private

Port to run server on.

◆ server

std::unique_ptr<Server> httpmock::MockServer::server
private

Server implementation.


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