- Category
- Protocol - HTTP networking
Demonstrates:
- Creating HTTP server with http_facade
- Creating HTTP client with http_facade
- Configuration via config structs
- See also
- kcenon::network::facade::http_facade
#include <iostream>
#include <string>
{
std::cout << "=== HTTP Facade Example ===" << std::endl;
srv_config.
server_id =
"example-http-server";
std::cout << "\n1. Creating HTTP server..." << std::endl;
std::cout <<
" Port: " << srv_config.
port << std::endl;
std::cout <<
" Server ID: " << srv_config.
server_id << std::endl;
auto server = facade::http_facade::create_server(srv_config);
if (server)
{
std::cout << " Server created successfully" << std::endl;
}
else
{
std::cout << " Server creation returned null (expected in demo)" << std::endl;
}
cli_config.
client_id =
"example-http-client";
cli_config.
timeout = std::chrono::seconds(30);
std::cout << "\n2. Creating HTTP client..." << std::endl;
std::cout <<
" Client ID: " << cli_config.
client_id << std::endl;
std::cout <<
" Timeout: " << cli_config.
timeout.count() <<
"ms" << std::endl;
std::cout <<
" SSL: " << (cli_config.
use_ssl ?
"enabled" :
"disabled") << std::endl;
auto client = facade::http_facade::create_client(cli_config);
if (client)
{
std::cout << " Client created successfully" << std::endl;
}
else
{
std::cout << " Client creation returned null (expected in demo)" << std::endl;
}
std::cout << "\nDone." << std::endl;
return 0;
}
Simplified facade for creating HTTP clients and servers.
Main namespace for all Network System components.
Configuration for creating an HTTP client.
std::string client_id
Client identifier (auto-generated if not provided)
bool use_ssl
Whether to use HTTPS.
std::chrono::milliseconds timeout
Request timeout.
Configuration for creating an HTTP server.
uint16_t port
Port number to listen on.
std::string server_id
Server identifier (optional, auto-generated if not provided)