| 71 | // Returns a sender that yields an http_request object for an incoming request |
| 72 | template <ex::scheduler S> |
| 73 | auto schedule_request_start(S sched, int idx) -> ex::sender auto |
| 74 | { |
| 75 | // app-specific-details: building of the http_request object |
| 76 | auto url = std::string("/query?image_idx=") + std::to_string(idx); |
| 77 | if (idx == 7) |
| 78 | url.clear(); // fake invalid request |
| 79 | http_request req{.url_ = std::move(url), .headers_ = {}, .body_ = {}}; |
| 80 | std::cout << "HTTP request " << idx << " arrived\n"; |
| 81 | |
| 82 | // Return a sender for the incoming http_request |
| 83 | return ex::just(std::move(req)) | ex::continues_on(std::forward<S>(sched)); |
| 84 | } |
| 85 | |
| 86 | // Sends a response back to the client; yields a void signal on success |
| 87 | auto send_response(http_response const & resp) -> ex::sender auto |