SMACC2
Loading...
Searching...
No Matches
cl_http.hpp
Go to the documentation of this file.
1// Copyright 2023 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Jaycee Lock & Brett Aldrich
18 *
19 * Description: HTTP/HTTPS Client using pure component-based architecture
20 *
21 * Architecture:
22 * ClHttp (minimal orchestrator) creates and configures three components:
23 * - CpHttpConnectionManager: io_context and thread management
24 * - CpHttpSessionManager: SSL context and session creation
25 * - CpHttpRequestExecutor: Request execution and response signals
26 *
27 * Usage:
28 * Behaviors should access CpHttpRequestExecutor component directly via requiresComponent()
29 * and connect to its onResponseReceived_ signal for HTTP responses.
30 *
31 * See README.md for complete documentation and examples.
32 *
33 ******************************************************************************************************************/
34
35#pragma once
36
42#include <string>
43
44namespace cl_http
45{
62{
63public:
65 {
66 GET = static_cast<int>(boost::beast::http::verb::get),
67 POST = static_cast<int>(boost::beast::http::verb::post),
68 PUT = static_cast<int>(boost::beast::http::verb::put),
69 };
70
72
73 explicit ClHttp(const std::string & server, const int & timeout = 1500);
74
75 virtual ~ClHttp();
76
77 void onInitialize() override;
78
79 // Component composition during orthogonal initialization
80 template <typename TOrthogonal, typename TClient>
94
95private:
96 const int HTTP_VERSION = 11;
97
99
100 std::string server_url_; // Server URL for component configuration
101
102 // Component references
106};
107} // namespace cl_http
HTTP/HTTPS client with pure component-based architecture.
Definition cl_http.hpp:62
ClHttp(const std::string &server, const int &timeout=1500)
Definition cl_http.cpp:25
http_session_base::TResponse TResponse
Definition cl_http.hpp:71
CpHttpRequestExecutor * requestExecutor_
Definition cl_http.hpp:105
std::string server_url_
Definition cl_http.hpp:100
void onInitialize() override
Definition cl_http.cpp:40
CpHttpConnectionManager * connectionManager_
Definition cl_http.hpp:103
void onComponentInitialization()
Definition cl_http.hpp:81
const int HTTP_VERSION
Definition cl_http.hpp:96
virtual ~ClHttp()
Definition cl_http.cpp:35
CpHttpSessionManager * sessionManager_
Definition cl_http.hpp:104
void setDependencies(CpHttpConnectionManager *connMgr, CpHttpSessionManager *sessMgr)
void setServerUrl(const std::string &server_url)
boost::beast::http::response< boost::beast::http::string_body > TResponse
SmaccComponentType * createComponent(TArgs... targs)