Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
http_facade_example.cpp File Reference

Demonstrates HTTP facade for simplified server/client creation. More...

#include <kcenon/network/facade/http_facade.h>
#include <iostream>
#include <string>
Include dependency graph for http_facade_example.cpp:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Demonstrates HTTP facade for simplified server/client creation.

Definition in file http_facade_example.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 31 of file http_facade_example.cpp.

32{
33 std::cout << "=== HTTP Facade Example ===" << std::endl;
34
35 // Server configuration
37 srv_config.port = 8080;
38 srv_config.server_id = "example-http-server";
39
40 std::cout << "\n1. Creating HTTP server..." << std::endl;
41 std::cout << " Port: " << srv_config.port << std::endl;
42 std::cout << " Server ID: " << srv_config.server_id << std::endl;
43
45 if (server)
46 {
47 std::cout << " Server created successfully" << std::endl;
48 }
49 else
50 {
51 std::cout << " Server creation returned null (expected in demo)" << std::endl;
52 }
53
54 // Client configuration
56 cli_config.client_id = "example-http-client";
57 cli_config.timeout = std::chrono::seconds(30);
58 cli_config.use_ssl = false;
59
60 std::cout << "\n2. Creating HTTP client..." << std::endl;
61 std::cout << " Client ID: " << cli_config.client_id << std::endl;
62 std::cout << " Timeout: " << cli_config.timeout.count() << "ms" << std::endl;
63 std::cout << " SSL: " << (cli_config.use_ssl ? "enabled" : "disabled") << std::endl;
64
66 if (client)
67 {
68 std::cout << " Client created successfully" << std::endl;
69 }
70 else
71 {
72 std::cout << " Client creation returned null (expected in demo)" << std::endl;
73 }
74
75 std::cout << "\nDone." << std::endl;
76 return 0;
77}
auto create_server(const server_config &config) const -> Result< std::shared_ptr< interfaces::i_protocol_server > >
Creates an HTTP server with the specified configuration.
auto create_client(const client_config &config) const -> Result< std::shared_ptr< interfaces::i_protocol_client > >
Creates an HTTP client with the specified configuration.
@ server
Server-side handling of a request.
Configuration for creating an HTTP client.
Definition http_facade.h:84
std::string client_id
Client identifier (auto-generated if not provided)
Definition http_facade.h:86
std::chrono::milliseconds timeout
Request timeout.
Definition http_facade.h:89
Configuration for creating an HTTP server.
std::string server_id
Server identifier (optional, auto-generated if not provided)

References kcenon::network::facade::http_facade::client_config::client_id, kcenon::network::facade::http_facade::create_client(), kcenon::network::facade::http_facade::create_server(), kcenon::network::facade::http_facade::server_config::port, kcenon::network::facade::http_facade::server_config::server_id, kcenon::network::facade::http_facade::client_config::timeout, and kcenon::network::facade::http_facade::client_config::use_ssl.

Here is the call graph for this function: