MCPcopy Create free account
hub / github.com/actor-framework/actor-framework / lift

Method lift

libcaf_net/caf/net/http/router.cpp:37–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35// -- API for the responders ---------------------------------------------------
36
37request router::lift(responder&& res) {
38 auto prom = async::promise<response>();
39 auto fut = prom.get_future();
40 auto buf = std::vector<std::byte>{res.payload().begin(), res.payload().end()};
41 auto lifted = request{res.header(), std::move(buf), std::move(prom)};
42 auto request_id = request_id_++;
43 auto hdl = fut.bind_to(down_->mpx())
44 .then(
45 [this, request_id](const response& res) {
46 down_->begin_header(res.code());
47 for (auto& [key, val] : res.header_fields())
48 down_->add_header_field(key, val);
49 std::ignore = down_->end_header();
50 down_->send_payload(res.body());
51 pending_.erase(request_id);
52 },
53 [this, request_id](const error& err) {
54 auto description = to_string(err);
55 down_->send_response(status::internal_server_error,
56 "text/plain", description);
57 pending_.erase(request_id);
58 });
59 pending_.emplace(request_id, std::move(hdl));
60 return lifted;
61}
62
63void router::shutdown(const error& err) {
64 abort_and_shutdown(err);

Callers 1

to_requestMethod · 0.45

Calls 15

payloadMethod · 0.80
bind_toMethod · 0.80
bodyMethod · 0.80
send_responseMethod · 0.80
to_stringFunction · 0.50
get_futureMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
headerMethod · 0.45
thenMethod · 0.45
begin_headerMethod · 0.45
add_header_fieldMethod · 0.45

Tested by

no test coverage detected