Closed zethon closed 6 years ago
You can do like this:
HttpServer _server;
_server.config.port = 8080;
_server.resource["^/shutdown$"]["GET"] = [&](std::shared_ptr<HttpServer::Response> response,
std::shared_ptr<HttpServer::Request> /*request*/) {
response->write("<h1>Shutting down!</h1>"); // Write to stream
response->send([&](const SimpleWeb::error_code & /*ec*/) { // Send stream over network
_server.stop(); // When send has finished, successful or not, stop the server
});
};
_server.start();
return 0;
I have a handler where I want to shut the server down once I've written a response... for example:
The problem is that
response->write(stream);
returns immediately. Is there a synchronous way of doing this?