<commit_before>#include <application/application.hpp>
#include <boost/regex.hpp>

using namespace express;

application::application() {

}

void application::get(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::get,route,rHandler);
}

void application::post(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::post,route,rHandler);
}

void application::put(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::put,route,rHandler);
}

void application::del(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::del,route,rHandler);
}

void application::register_route(const http_verb verb,const routePath route,const routeHandler rHandler) {

    actions _actions;
    handler _handler;
    _handler.func = rHandler;

    //extracting route parameters
    boost::regex params_regex(regxParam);
    boost::sregex_iterator next(route.begin(), route.end(), params_regex);
    boost::sregex_iterator end;
    //first element is for complete path
    _handler.params.push_back("path");

    while (next != end) {
        boost::smatch match = *next;
        _handler.params.push_back(match.str(1));
        next++;
    }

    //handling trailing edge

    //rewriting route as regular regex
    std::string regex_route = boost::regex_replace(route,params_regex,regxURI);

    _actions.insert(std::make_pair(verb,_handler));
    _routing.insert(std::make_pair(regex_route,_actions));

}

void application::listen(int port) {

    HttpServer server(port,4);

    server.default_resource["GET"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::get,res,req);
    };

    server.default_resource["POST"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::post,res,req);
    };

    server.default_resource["PUT"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::put,res,req);
    };

    server.default_resource["DELETE"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::del,res,req);
    };

    std::thread server_thread([&server](){
        server.start();
    });

    server_thread.join();
}

void application::static_(const boost::filesystem::path rootPath)
{
    namespace fs = boost::filesystem;
    if(!(fs::exists(rootPath) && fs::is_directory(rootPath)))<commit_msg>FEATURE: improved size of thread pool<commit_after>#include <application/application.hpp>
#include <boost/regex.hpp>

using namespace express;

application::application() {

}

void application::get(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::get,route,rHandler);
}

void application::post(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::post,route,rHandler);
}

void application::put(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::put,route,rHandler);
}

void application::del(const routePath route,const routeHandler rHandler) {

    register_route(http_verb::del,route,rHandler);
}

void application::register_route(const http_verb verb,const routePath route,const routeHandler rHandler) {

    actions _actions;
    handler _handler;
    _handler.func = rHandler;

    //extracting route parameters
    boost::regex params_regex(regxParam);
    boost::sregex_iterator next(route.begin(), route.end(), params_regex);
    boost::sregex_iterator end;
    //first element is for complete path
    _handler.params.push_back("path");

    while (next != end) {
        boost::smatch match = *next;
        _handler.params.push_back(match.str(1));
        next++;
    }

    //handling trailing edge

    //rewriting route as regular regex
    std::string regex_route = boost::regex_replace(route,params_regex,regxURI);

    _actions.insert(std::make_pair(verb,_handler));
    _routing.insert(std::make_pair(regex_route,_actions));

}

void application::listen(int port) {

    HttpServer server(port,8);

    server.default_resource["GET"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::get,res,req);
    };

    server.default_resource["POST"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::post,res,req);
    };

    server.default_resource["PUT"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::put,res,req);
    };

    server.default_resource["DELETE"]=[&](HttpServer::Response& res, std::shared_ptr<HttpServer::Request> req) {
        connect_route(http_verb::del,res,req);
    };

    std::thread server_thread([&server](){
        server.start();
    });

    server_thread.join();
}

void application::static_(const boost::filesystem::path rootPath)
{
    namespace fs = boost::filesystem;
    if(!(fs::exists(rootPath) && fs::is_directory(rootPath)))
{'fraction_non_alphanumeric': 0.1406926406926407, 'fraction_numerical': 0.0007870916961826052, 'mean_word_length': 5.094724220623501, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2113111', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1525, 'n_words': 258}