RESTinio-0.4
2017.12.27
We would like to announce next release of RESTinio a header-only C++14 library that gives you an embedded HTTP server with nice express-like routing (although it is not mandatory to use router) and websockets on board. See of previous release on reddit.
What's new:
- Timer manager concept introduced. Timers performance improved.
- Express router: introduce a concept of regex engine, so express router can run on pcre/pcre2 engines or the one provided by user.
For example you can use PCRE library for regex:
using router_t = restinio::router::express_router_t< restinio::router::pcre_regex_engine_t >; auto router = std::make_unique< router_t >(); router->http_get( "/:id(\d{8})/:tag", []( auto req, auto params ){ // Handle request. } ); // Add more routes ...
- Express router: introducing functions for converting route parameters to a specific type (if conversion is available).
router->http_get( "/search/:user_id(\d{8})/:tag", []( auto req, auto params ){ const auto id = restinio::cast_as< unsigned int >(params["user_id"]); const auto tag = restinio::cast_as< std::string >(params["tag"]); const auto posts = get_users_posts( id, tag ); if( posts.empty() ) return req->create_response( 404, "Not found") .append_header( "Server", "RESTinio routers example" ) .append_header_date_field() .connection_close() .done(); // Has posts return write_posts_response( std::move( req ), posts ); } );
- Express router: getting rid of using strings for storing parameters keys and values in route_params_t and using string_view (std::string_view if available).
- Express router: update route to regex processing in order to stick with path-to-regexp project.
- Express router: a handler for non matched request can be set.
router->non_matched_request_handler( []( auto req ){ return req->create_response( 404, "Not found") .append_header_date_field() .connection_close() .done(); } );
- Express router: add a benchmark for testing performance on a given set of routes (described in file), this makes it possible to do quick benchmark of RESTinio+router performance on a given set of routes.
- Improve query string params. Parsed parameters stored as string_view objects, thus requiring less space and less allocations.
- Add benchmarks: add benchmarks for a single handler servers.
- Add cmake support for SObjectizer dependent test and samples.
- Documentation moved here.