Your opinion will help to improve our service
Leave a feedback >#include <userver/utest/simple_server.hpp>
Toy server for simple network testing; for testing HTTP prefer using utest::HttpServerMock.
In constructor opens specified ports in localhost address and listens on them. On each accepted data packet calls user callback.
Definition at line 26 of file simple_server.hpp.
Classes | |
struct | Response |
Response to return from the OnRequest callback. More... | |
Public Types | |
enum | Protocol { kTcpIpV4 , kTcpIpV6 } |
enum class | Schema { kHttp , kHttps } |
using | Request = std::string |
Request that is passed to the OnRequest callback. | |
using | OnRequest = std::function<Response(const Request&)> |
Callback that is invoked on each network request. | |
using | Port = unsigned short |
Public Member Functions | |
SimpleServer (OnRequest callback, Protocol protocol=kTcpIpV4) | |
Port | GetPort () const |
Returns Port the server listens on. | |
std::string | GetBaseUrl (Schema type=Schema::kHttp) const |
Returns URL to the server, for example 'http://127.0.0.1:8080'. | |
std::uint64_t | GetConnectionsOpenedCount () const |
using utest::SimpleServer::OnRequest = std::function<Response(const Request&)> |
Callback that is invoked on each network request.
Definition at line 46 of file simple_server.hpp.
using utest::SimpleServer::Port = unsigned short |
Definition at line 48 of file simple_server.hpp.
using utest::SimpleServer::Request = std::string |
Request that is passed to the OnRequest callback.
Definition at line 43 of file simple_server.hpp.
enum utest::SimpleServer::Protocol |
Definition at line 49 of file simple_server.hpp.
|
strong |
Definition at line 57 of file simple_server.hpp.