someone said
[ghsmtp.git] / jnk / h2-server.cpp
blob674ddb7146f57e8e51a7dd777d16dcd4df0fe026
1 #include <iostream>
3 #include <nghttp2/asio_http2_server.h>
5 using namespace nghttp2::asio_http2;
6 using namespace nghttp2::asio_http2::server;
8 int main(int argc, char* argv[])
10 boost::system::error_code ec;
11 boost::asio::ssl::context tls(boost::asio::ssl::context::sslv23);
13 tls.use_private_key_file("smtp.key", boost::asio::ssl::context::pem);
14 tls.use_certificate_chain_file("smtp.pem");
16 configure_tls_context_easy(ec, tls);
18 http2 server;
20 server.handle("/index.html", [](const request& req, const response& res) {
21 res.write_head(200);
22 res.end(file_generator("index.html"));
23 });
25 if (server.listen_and_serve(ec, tls, "localhost", "3000")) {
26 std::cerr << "error: " << ec.message() << std::endl;