RESTinio v0.6.6 Release Notes

Release Date: 2020-04-13 // about 4 years ago
  • An experimental type-safe request-router that can be used as a type-safe alternative of express-like router with additional compile-time checking. That new easy_parser_router allows to write:

    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) {...});
    

    instead of:

    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"]); });
    

    👀 An ability to specify a request handler for several HTTP-methods (see #82 for a motivation). 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. Thanks for @prince-chrismc for a patch.