userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
http_server_mock.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <cstdint>
7
#include <map>
8
9
#include <
userver/utest/simple_server.hpp
>
10
11
#include <
userver/clients/http/request.hpp
>
12
#include <
userver/clients/http/response.hpp
>
13
14
USERVER_NAMESPACE_BEGIN
15
16
namespace
utest
{
17
27
class
HttpServerMock {
28
public
:
30
struct
HttpRequest
{
31
clients::http::HttpMethod
method{clients::http::HttpMethod::kGet};
32
std::string path;
33
34
std::multimap<std::string, std::string> query;
35
clients::http::Headers
headers;
36
std::string body;
37
};
38
40
struct
HttpResponse
{
41
int
response_status{200};
42
clients::http::Headers
headers;
43
std::string body;
44
};
45
47
using
HttpHandler
= std::function<
HttpResponse
(
const
HttpRequest
&)>;
48
49
HttpServerMock(
HttpHandler
http_handler, SimpleServer::Protocol protocol = SimpleServer::kTcpIpV4);
50
52
std::string
GetBaseUrl
()
const
;
53
55
SimpleServer::Port
GetPort
()
const
;
56
57
std::uint64_t GetConnectionsOpenedCount()
const
;
58
59
private
:
60
friend
class
HttpConnection;
61
62
HttpHandler
http_handler_;
63
SimpleServer
server_;
64
};
65
66
}
// namespace utest
67
68
USERVER_NAMESPACE_END
userver
utest
http_server_mock.hpp
Generated on
for userver by
Doxygen
1.17.0