The main features of v.0.6.7.1 are:
-----
New configuration options for CMake-based builds:
- RESTINIO_USE_EXTERNAL_EXPECTED_LITE,
- RESTINIO_USE_EXTERNAL_OPTIONAL_LITE,
- RESTINIO_USE_EXTERNAL_STRING_VIEW_LITE,
- RESTINIO_USE_EXTERNAL_VARIANT_LITE.
-----
New helper function run_async that allows to run an instance of RESTinio's server on a separate thread-pool or thread:
int main() {
auto server = restinio::run_async(
// Asio's io_context to be used.
// HTTP-server will use own Asio's io_context object.
restinio::own_io_context(),
// The settings for the HTTP-server.
restinio::server_settings_t{}
.address("127.0.0.1")
.port(8080)
.request_handler(...),
// The size of thread-pool for the HTTP-server.
16);
// If we are here and run_async doesn't throw then HTTP-server
// is started.
... // Some other actions.
// No need to stop HTTP-server manually. It will be automatically
// stopped in the destructor of `server` object.
}
-----
New helpers for working with HTTP-fields like Authorization and Proxy-Authorization, and helpers for the extraction of parameters for:
Basic authentication:
#include <restinio/all.hpp>
#include <restinio/http_field_parser/basic_auth.hpp>
...
auto on_request(const restinio::request_handle_t & req) {
using namespace restinio::http_field_parsers::basic_auth;
const auto auth_params = try_extract_params(*req,
restinio::http_field::authorization);
if(auth_params) { // Parameters successfully extracted.
if(is_valid_user(auth_params->username, auth_params->password)) {
...
}
}
...
}
And the same helpers for Bearer authentication:
#include <restinio/all.hpp>
#include <restinio/http_field_parser/bearer_auth.hpp>
...
auto on_request(const restinio::request_handle_t & req) {
using namespace restinio::http_field_parsers::bearer_auth;
const auto auth_params = try_extract_params(*req,
restinio::http_field::authorization);
if(auth_params) { // Parameters successfully extracted.
if(is_valid_user(auth_params->client_id, auth_params->client_secret)) {
...
}
}
...
}
-----
Some bug-fixes.
-----
This version is already available via Conan. We sent our PR to vcpkg, RESTinio-0.6.6 will be available via vcpkg as soon as our PR will be accepted.