-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathsimple_server.cpp
More file actions
28 lines (20 loc) · 891 Bytes
/
simple_server.cpp
File metadata and controls
28 lines (20 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "simple_server.hpp"
#include <userver/components/component_context.hpp>
#include <userver/engine/io/socket.hpp>
#include "simple_connection.hpp"
#include "simple_router.hpp"
namespace userver_httparena::bare {
SimpleServer::SimpleServer(const userver::components::ComponentConfig& config,
const userver::components::ComponentContext& context)
: userver::components::TcpAcceptorBase(config, context),
router_{context.FindComponent<SimpleRouter>()} {}
SimpleServer::~SimpleServer() = default;
void SimpleServer::ProcessSocket(userver::engine::io::Socket&& socket) {
const auto fd = socket.Fd();
connections_[fd] =
std::make_unique<SimpleConnection>(*this, std::move(socket));
}
SimpleResponse SimpleServer::HandleRequest(std::string_view url) const {
return router_.RouteRequest(url);
}
} // namespace userver_httparena::bare