matador::http::client Class Reference

A http client class. More...

#include <http_client.hpp>

Public Member Functions

 client (const std::string &host)
 
response get (const std::string &route)
 
response post (const std::string &route, const std::string &body)
 
response put (const std::string &route, const std::string &body)
 
response remove (const std::string &route)
 

Detailed Description

A http client class.

This class represents a http client connection. The class is initialized with the remote endpoint url consisting of a hostname or ip address and optional a port <host[:port]>.

It provides the four main http commands

  • GET
  • PUT
  • POST
  • DELETE

Once on of the four command is called via provided method a connection is established and the request is send synchronously.

Once the answer is received and processed a response object is returned.

Constructor & Destructor Documentation

◆ client()

matador::http::client::client ( const std::string &  host)
explicit

Creates a client for the given host

Parameters
hostHost and optional port string

Member Function Documentation

◆ get()

response matador::http::client::get ( const std::string &  route)

Sends a GET request to the given route at the configured host.

Parameters
routeRoute to be requested
Returns
The response of the request

◆ post()

response matador::http::client::post ( const std::string &  route,
const std::string &  body 
)

Sends a POST request to the given route at the configured host with the given body as string.

Parameters
routeRoute to be requested
bodyString representing the body of the request
Returns
The response of the request

◆ put()

response matador::http::client::put ( const std::string &  route,
const std::string &  body 
)

Sends a PUT request to the given route at the configured host with the given body as string.

Parameters
routeRoute to be requested
bodyString representing the body of the request
Returns
The response of the request

◆ remove()

response matador::http::client::remove ( const std::string &  route)

Sends a DELETE request to the given route at the configured host.

Parameters
routeRoute to be requested
Returns
The response of the request

The documentation for this class was generated from the following file:
  • matador/http/http_client.hpp