Malloy
|
#include <controller.hpp>
Classes | |
struct | config |
Public Types | |
using | session = malloy::detail::controller_run_result< std::shared_ptr< boost::asio::ssl::context > > |
Public Member Functions | |
controller (config cfg) | |
~controller ()=default | |
bool | init_tls () |
template<malloy::http::concepts::body ReqBody, typename Callback , concepts::response_filter Filter = detail::default_resp_filter> requires concepts::http_callback<Callback, Filter> | |
std::future< malloy::error_code > | http_request (malloy::http::request< ReqBody > req, Callback &&done, Filter filter={}) |
template<malloy::http::concepts::body ReqBody, typename Callback , concepts::response_filter Filter = detail::default_resp_filter> requires concepts::http_callback<Callback, Filter> | |
std::future< malloy::error_code > | https_request (malloy::http::request< ReqBody > req, Callback &&done, Filter filter={}) |
void | wss_connect (const std::string &host, std::uint16_t port, const std::string &resource, std::invocable< malloy::error_code, std::shared_ptr< websocket::connection > > auto &&handler) |
Same as ws_connect() but uses TLS. | |
void | add_ca_file (const std::filesystem::path &file) |
Load a certificate authority for use with TLS validation. | |
void | add_ca (const std::string &contents) |
Like add_ca_file(std::filesystem::path) but loads from an in-memory string. | |
void | ws_connect (const std::string &host, std::uint16_t port, const std::string &resource, std::invocable< malloy::error_code, std::shared_ptr< websocket::connection > > auto &&handler) |
Friends | |
session | start (controller &ctrl) |
High-level controller for client activities.
using malloy::client::controller::session = malloy::detail::controller_run_result<std::shared_ptr<boost::asio::ssl::context> > |
Session type.
|
explicit |
Constructor.
cfg | The configuration. |
|
default |
Destructor.
void controller::add_ca | ( | const std::string & | contents | ) |
Like add_ca_file(std::filesystem::path) but loads from an in-memory string.
contents | The certificate to be added to the keychain |
void controller::add_ca_file | ( | const std::filesystem::path & | file | ) |
Load a certificate authority for use with TLS validation.
file | The path to the certificate to be added to the keychain |
|
inline |
Perform a plain (unencrypted) HTTP request.
req | The HTTP request. |
done | Callback invoked on completion. Must satisfy http_callback (Client Concepts) with Filter |
filter | Filter to use when parsing the response. Must satisfy response_filter Client Concepts |
|
inline |
Same as http_request() but encrypted with TLS.
bool controller::init_tls | ( | ) |
Initialize the TLS context.
|
inline |
Create a websocket connection.
host | The host. |
port | The port. |
resource | The suburl to connect to (e.g. /api/websocket ) |
handler | Callback invoked when the connection is established (successfully or otherwise). Must satisfy f(e, c) , where:
|
handler
is truthy (an error) the connection will be nullptr
|
inline |