ASIO Support
Originally RESTinio was based on a stand-alone version of asio. We choose ASIO as it is aimed to be part of a standard. And its stand-alone version is closer to a final result. ASIO has also a Boost version, that is, by the way, more widely known. But prior to 1.66 Boost::ASIO has an older interface compared to the one in stand-alone version representing the Networking TS. Since 1.66 Boost::ASIO implementation was updated and became an equivalent to stand-alone version. And so it became possible to support both stand-alone and Boost version of ASIO.
Since v.0.4.1 RESTinio supports Boost::ASIO.
To use Boost::ASIO it is needed to define macros RESTINIO_USE_BOOST_ASIO
.
It can be done by the build tool or by defining it prior to including RESTinio:
#define RESTINIO_USE_BOOST_ASIO
#include <restinio/all.hpp>
ASIO Versions
For stand-alone version, we picked a some of the latest commits from master branch to be closer to Networking TS and for Boost::ASIO we picked 1.66 the latest version at the moment (Jan 2018).
Linking tips
By default Boost::ASIO depends on Boost::System, that is not a header-only.
So when using RESTinio with Boost::ASIO one should take care of adding
boost_system
to a list of libraries to link to a binary.
Implementation details
All RESTinio internal files rely on restinio/asio_include.hpp
to get the right version of ASIO. asio_include.hpp
wrapps original ASIO namespace
(asio::*
or boost::asio::*
) to restinio::asio_ns
that is used by RESTinio implementation and interfaces.
When using a concrete ASIO, it is perfectly well to refer
to ASIO namespace directly in your code (asio::*
or boost::asio::*
),
it’s just for the purpose of using both versions of ASIO
that RESTinio uses a surrogate asio namespace internally.