RESTinio 0.6.6 Released!

2020.04.14

A new experimental typesafe router added. It can be used instead of express-like router.

This new easy_parser_router allows to describe routes that way:

namespace epr = restinio::router::easy_parser_router;
router->http_get(
   epr::path_to_params("/api/v1/posts/",
      epr::non_negative_decimal_number_p<std::uint64_t>(),
      "/revisions/",
      epr::non_negative_decimal_number_p<std::int16_t>()),
   [](const auto & req, std::uint64_t post_id, std::int16_t rev_id) {...});

The same router can be described for express-like router that way:

router->http_get("/api/v1/posts/:post_id(\d{1,10})/revisions/:rev_id(\d{1,5})",
   [](const auto & req, const auto & params) {
      const auto post_id = restinio::cast_to<std::uint64_t>(params["post_id"]);
      const auto rev_id = restinio::cast_to<std::int16_t>(params["rev_id"]);
      ...
   });

New easy_parser_router relies on compile-time checks from the C++ compiler. That allows to avoid some mistakes related to express-like router.

An ability to specify a request handler for several HTTP-methods. It's possible now to write routes like:

router->add_handler(
   restinio::router::any_of_methods(
      restinio::http_method_lock(), restinio::http_method_unlock()),
   "/api/v1/resources/:rid",
   [](const auto & req, const auto & params) {...});

router->add_handler(
   restinio::router::none_of_methods(
      restinio::http_method_get(), restinio::http_method_post(), restinio::http_method_delete()),
   "/api/v1/users/:user",
   [](const auto & req, const auto & params) {...});

Those new method matchers can be used for express-like or easy_parser-based routers.

New RESTINIO_FMT_HEADER_ONLY CMake option added. It allows to use the compiled version of fmtlib with RESTinio.

The new version of RESTinio is available in the main repository on github. It also can be obtained via vcpkg and conan dependency management systems.

Doxygen documentation is also available: RESTinio-0.6 API Reference.

If you miss something in RESTinio and want to see some new features let us know via Issues on github or Google-group, or by writing to info@stiffstream.com. You can also order the addition of some specific functionality to RESTinio.