diff --git a/src/HttpRouter.h b/src/HttpRouter.h index 66ca17e..abba76b 100644 --- a/src/HttpRouter.h +++ b/src/HttpRouter.h @@ -30,6 +30,8 @@ #include #include +#include "f2/function2.hpp" + namespace uWS { template @@ -59,7 +61,9 @@ private: } } routeParameters; - std::vector)>> handlers; + std::vector)>> handlers; + + HttpRouter(const HttpRouter &other) = delete; struct Node { std::string name; @@ -190,7 +194,7 @@ public: } /* Register a route to be routed */ - HttpRouter *add(std::string method, std::string_view pattern, std::function)> handler) { + HttpRouter *add(std::string method, std::string_view pattern, fu2::unique_function)> &&handler) { /* Step over any initial slash */ if (pattern[0] == '/') { pattern = pattern.substr(1); @@ -215,7 +219,7 @@ public: /* Add this handler to the list of handlers */ short handlerIndex = handlers.size(); - handlers.push_back(handler); + handlers.emplace_back(std::move(handler)); /* Build the routing tree */ Node *parent = &tree;