RESTinio v0.6.11 Release Notes

Release Date: 2020-10-22 // over 3 years ago
  • 📜 Conversion functions passed to restinio::easy_parser::convert can now return expected_t<T, error_reason_t> as well as just T. Returning expected_t<T, error_reason_t> allows to report conversion errors without throwing an exception. This is a fix for #99.

    A new overload for restinio::server_settings_t::address() method. The new overload accepts an instance of asio::ip::address (or boost::asio::ip::address). This is a fix for #100.

    A new optional post-bind hook added. This hook is called just after a succesful return from bind() for server’s acceptor. A reference to asio::ip::tcp::acceptor is passed to that hook. This new hook can be used for application-specific tuning of bound acceptor or to gathering some information about the acceptor. This is a fix for #126. For example, this code snippet shows how RESTinio server can be started on a random port assigned by the Operating System:

    std::promise\<unsigned short\> port\_promise; // For getting the port.auto server = restinio::run\_async( restinio::use\_own\_context(), restinio::server\_settings\_t{} .address("localhost") .port(0u) // Zero means that port will be assigned by the OS. .acceptor\_post\_bind\_hook( [&port\_promise](asio::ip::tcp::acceptor & acceptor) { // Gathering the actual port number. port\_promise.set\_value(acceptor.local\_endpoint().port()); }) .request\_handler(...), 4u);// Now we can safely get the actual port number from the promise.const auto actual\_port = port\_promise.get\_future().get();