AXIAM C++ SDK 1.0.0-alpha8
Authentication, authorization, JWKS & route guards (REST + mTLS)
Loading...
Searching...
No Matches
transport.hpp
Go to the documentation of this file.
1// HTTP transport seam. The client depends only on the std::function<HttpResponse(
2// const HttpRequest&)> alias below; the default implementation is libcurl
3// (http_curl.hpp), and tests substitute an in-memory fake for full coverage of
4// the logic layer without any network.
5#pragma once
6
7#include <functional>
8#include <map>
9#include <string>
10#include <vector>
11
12#include "axiam/sensitive.hpp"
13
14namespace axiam {
15
18 bool operator()(const std::string& a, const std::string& b) const {
19 return lower(a) < lower(b);
20 }
21 static std::string lower(std::string s) {
22 for (char& c : s) {
23 if (c >= 'A' && c <= 'Z') c = static_cast<char>(c - 'A' + 'a');
24 }
25 return s;
26 }
27};
28
29using HeaderMap = std::map<std::string, std::string, CaseInsensitiveLess>;
30
33 std::string method; // "GET", "POST", ...
34 std::string url; // fully-qualified
36 std::string body; // JSON body (may be empty)
37};
38
43 long status = 0;
50 std::vector<std::string> set_cookies;
51 std::string body;
52 std::string transport_error; // empty on a completed HTTP exchange
53};
54
56using Transport = std::function<HttpResponse(const HttpRequest&)>;
57
61struct TlsConfig {
62 std::string custom_ca_pem; // optional additional trusted CA (PEM)
63 std::string client_cert_pem; // optional mTLS client cert chain (PEM)
64 Sensitive<std::string> client_key_pem; // optional mTLS private key (PEM, ยง7)
65 long connect_timeout_ms = 10000;
66 long request_timeout_ms = 30000;
67
83
84 bool has_client_cert() const {
85 return !client_cert_pem.empty() && !client_key_pem.empty();
86 }
87 bool has_custom_ca() const { return !custom_ca_pem.empty(); }
88};
89
90} // namespace axiam
Wraps secret material (access tokens, mTLS private keys).
Definition sensitive.hpp:26
bool empty() const
True when no secret is held (default-constructed / empty string).
Definition sensitive.hpp:40
Definition authenticator.hpp:40
std::function< HttpResponse(const HttpRequest &)> Transport
The transport seam. Injectable; defaults to the libcurl implementation.
Definition transport.hpp:56
std::map< std::string, std::string, CaseInsensitiveLess > HeaderMap
Definition transport.hpp:29
Case-insensitive header map key comparison.
Definition transport.hpp:17
static std::string lower(std::string s)
Definition transport.hpp:21
bool operator()(const std::string &a, const std::string &b) const
Definition transport.hpp:18
An outgoing HTTP request produced by the client's request builder.
Definition transport.hpp:32
std::string method
Definition transport.hpp:33
std::string url
Definition transport.hpp:34
std::string body
Definition transport.hpp:36
HeaderMap headers
Definition transport.hpp:35
An HTTP response, or a transport failure.
Definition transport.hpp:42
std::string body
Definition transport.hpp:51
long status
Definition transport.hpp:43
HeaderMap headers
Definition transport.hpp:44
std::vector< std::string > set_cookies
Raw Set-Cookie header values, in arrival order.
Definition transport.hpp:50
std::string transport_error
Definition transport.hpp:52
Immutable TLS / mTLS material handed to the libcurl transport factory.
Definition transport.hpp:61
Sensitive< std::string > client_key_pem
Definition transport.hpp:64
long request_timeout_ms
Definition transport.hpp:66
long connect_timeout_ms
Definition transport.hpp:65
bool has_custom_ca() const
Definition transport.hpp:87
bool has_client_cert() const
Definition transport.hpp:84
std::string client_cert_pem
Definition transport.hpp:63
unsigned max_concurrent_requests
Maximum libcurl easy handles the transport keeps, i.e.
Definition transport.hpp:82
std::string custom_ca_pem
Definition transport.hpp:62