userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
s3_connection.hpp
1
#
pragma
once
2
3
#
include
<
string
>
4
#
include
<
string_view
>
5
6
#
include
<
userver
/
clients
/
http
/
request
.
hpp
>
7
#
include
<
userver
/
clients
/
http
/
response
.
hpp
>
8
#
include
<
userver
/
utils
/
str_icase
.
hpp
>
9
10
#
include
<
userver
/
s3api
/
clients
/
s3api
.
hpp
>
11
#
include
<
userver
/
s3api
/
models
/
fwd
.
hpp
>
12
#
include
<
userver
/
s3api
/
models
/
s3api_connection_type
.
hpp
>
13
14
USERVER_NAMESPACE_BEGIN
15
16
namespace
clients::http {
17
class
Client
;
18
}
19
20
namespace
s3api {
21
22
// Represents a connection to s3 api
23
// includes an url to the api and a http interface
24
class
S3Connection
:
public
std::enable_shared_from_this<
S3Connection
> {
25
public
:
26
S3Connection(
27
clients::http::
Client
& http_client,
28
S3ConnectionType connection_type,
29
std::string server_url,
30
const
ConnectionCfg
& params
31
)
32
: api_url_(std::move(server_url)),
33
connection_type_(connection_type),
34
http_client_(http_client),
35
config_(params)
36
{}
37
38
S3Connection(
const
S3Connection
& other) =
default
;
39
40
~S3Connection() =
default
;
41
42
static
std::string MakeHostHeader(std::string_view api_url, std::string_view bucket);
43
44
std::shared_ptr<clients::http::Response> RequestApi(
Request
& r, std::string_view method_name);
45
46
std::shared_ptr<clients::http::Response> DoStartApiRequest(
const
Request
& r)
const
;
47
48
std::shared_ptr<clients::http::Response> StartApiRequest(
const
Request
& r)
const
;
49
50
std::string GetHost()
const
{
return
api_url_; }
51
52
std::string GetHostHeader(
const
Request
& r)
const
;
53
54
void
UpdateConfig(
ConnectionCfg
&& config) { config_ = config; }
55
56
private
:
57
std::string GetUrl(
const
Request
& r, S3ConnectionType connection_type)
const
;
58
59
ConnectionCfg
GetConfig()
const
{
return
config_; }
60
61
const
std::string api_url_;
62
S3ConnectionType connection_type_;
63
clients::http::
Client
& http_client_;
64
ConnectionCfg
config_;
65
};
66
67
std::shared_ptr<
S3Connection
>
MakeS3Connection
(
68
clients::http::
Client
& http_client,
69
S3ConnectionType connection_type,
70
std::string server_url,
71
const
ConnectionCfg
& params
72
);
73
74
}
// namespace s3api
75
76
USERVER_NAMESPACE_END
src
s3api
s3_connection.hpp
Generated on
for userver by
Doxygen
1.17.0