| 67 | } |
| 68 | |
| 69 | int main( int argc, const char * argv[] ) |
| 70 | { |
| 71 | using namespace std::chrono; |
| 72 | |
| 73 | std::string certs_dir = "."; |
| 74 | |
| 75 | if( 2 == argc ) |
| 76 | { |
| 77 | certs_dir = argv[ 1 ]; |
| 78 | } |
| 79 | |
| 80 | try |
| 81 | { |
| 82 | using traits_t = |
| 83 | restinio::single_thread_tls_traits_t< |
| 84 | restinio::asio_timer_manager_t, |
| 85 | restinio::single_threaded_ostream_logger_t, |
| 86 | router_t >; |
| 87 | |
| 88 | // Since RESTinio supports both stand-alone ASIO and boost::ASIO |
| 89 | // we specify an alias for a concrete asio namesace. |
| 90 | // That's makes it possible to compile the code in both cases. |
| 91 | // Typicaly only one of ASIO variants would be used, |
| 92 | // and so only asio::* or only boost::asio::* would be applied. |
| 93 | namespace asio_ns = restinio::asio_ns; |
| 94 | |
| 95 | asio_ns::ssl::context tls_context{ asio_ns::ssl::context::sslv23 }; |
| 96 | tls_context.set_options( |
| 97 | asio_ns::ssl::context::default_workarounds |
| 98 | | asio_ns::ssl::context::no_sslv2 |
| 99 | | asio_ns::ssl::context::single_dh_use ); |
| 100 | |
| 101 | tls_context.use_certificate_chain_file( certs_dir + "/server.pem" ); |
| 102 | tls_context.use_private_key_file( |
| 103 | certs_dir + "/key.pem", |
| 104 | asio_ns::ssl::context::pem ); |
| 105 | tls_context.use_tmp_dh_file( certs_dir + "/dh2048.pem" ); |
| 106 | |
| 107 | restinio::run( |
| 108 | restinio::on_this_thread< traits_t >() |
| 109 | .address( "localhost" ) |
| 110 | .request_handler( server_handler() ) |
| 111 | .read_next_http_message_timelimit( 10s ) |
| 112 | .write_http_response_timelimit( 1s ) |
| 113 | .handle_request_timeout( 1s ) |
| 114 | .tls_context( std::move( tls_context ) ) ); |
| 115 | } |
| 116 | catch( const std::exception & ex ) |
| 117 | { |
| 118 | std::cerr << "Error: " << ex.what() << std::endl; |
| 119 | return 1; |
| 120 | } |
| 121 | |
| 122 | return 0; |
| 123 | } |
nothing calls this directly
no test coverage detected