summaryrefslogtreecommitdiffstats
path: root/ext/yahttp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:14:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:14:49 +0000
commit2f230033794fafdf10822568e763d4db68cf6c6b (patch)
tree39ca5c2325b7b43c9a28ca6d4ad4026a61e7eb97 /ext/yahttp
parentAdding debian version 1.8.3-3. (diff)
downloaddnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.tar.xz
dnsdist-2f230033794fafdf10822568e763d4db68cf6c6b.zip
Merging upstream version 1.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ext/yahttp')
-rw-r--r--ext/yahttp/Makefile.in30
-rw-r--r--ext/yahttp/yahttp/Makefile.in28
-rw-r--r--ext/yahttp/yahttp/cookie.hpp2
-rw-r--r--ext/yahttp/yahttp/reqresp.cpp2
-rw-r--r--ext/yahttp/yahttp/router.cpp134
-rw-r--r--ext/yahttp/yahttp/router.hpp31
-rw-r--r--ext/yahttp/yahttp/utility.hpp2
7 files changed, 146 insertions, 83 deletions
diff --git a/ext/yahttp/Makefile.in b/ext/yahttp/Makefile.in
index e6e5ece..3ca8537 100644
--- a/ext/yahttp/Makefile.in
+++ b/ext/yahttp/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -96,6 +96,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_pthread_set_name.m4 \
$(top_srcdir)/m4/ax_python_module.m4 $(top_srcdir)/m4/boost.m4 \
$(top_srcdir)/m4/dnsdist_enable_dnscrypt.m4 \
$(top_srcdir)/m4/dnsdist_enable_doh.m4 \
+ $(top_srcdir)/m4/dnsdist_enable_doh3.m4 \
+ $(top_srcdir)/m4/dnsdist_enable_doq.m4 \
$(top_srcdir)/m4/dnsdist_enable_tls_providers.m4 \
$(top_srcdir)/m4/dnsdist_with_cdb.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -115,6 +117,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_pthread_set_name.m4 \
$(top_srcdir)/m4/pdns_check_ragel.m4 \
$(top_srcdir)/m4/pdns_check_secure_memset.m4 \
$(top_srcdir)/m4/pdns_d_fortify_source.m4 \
+ $(top_srcdir)/m4/pdns_enable_coverage.m4 \
+ $(top_srcdir)/m4/pdns_enable_fuzz_targets.m4 \
$(top_srcdir)/m4/pdns_enable_ipcipher.m4 \
$(top_srcdir)/m4/pdns_enable_lto.m4 \
$(top_srcdir)/m4/pdns_enable_sanitizers.m4 \
@@ -132,10 +136,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_pthread_set_name.m4 \
$(top_srcdir)/m4/pdns_with_lua.m4 \
$(top_srcdir)/m4/pdns_with_net_snmp.m4 \
$(top_srcdir)/m4/pdns_with_nghttp2.m4 \
+ $(top_srcdir)/m4/pdns_with_quiche.m4 \
$(top_srcdir)/m4/pdns_with_re2.m4 \
$(top_srcdir)/m4/pdns_with_service_user.m4 \
- $(top_srcdir)/m4/systemd.m4 $(top_srcdir)/m4/warnings.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/pdns_with_xsk.m4 $(top_srcdir)/m4/systemd.m4 \
+ $(top_srcdir)/m4/warnings.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -195,10 +200,8 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
-am__DIST_COMMON = $(srcdir)/Makefile.in
+am__DIST_COMMON = $(srcdir)/Makefile.in README.md
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
@@ -230,6 +233,7 @@ AMTAR = @AMTAR@
AM_CPPFLAGS = @AM_CPPFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
+ARC4RANDOM_LIBS = @ARC4RANDOM_LIBS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -240,13 +244,16 @@ BOOST_ROOT = @BOOST_ROOT@
BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@
BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
+BPF_CFLAGS = @BPF_CFLAGS@
+BPF_LIBS = @BPF_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CDB_CFLAGS = @CDB_CFLAGS@
CDB_LIBS = @CDB_LIBS@
CFLAGS = @CFLAGS@
-CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -263,8 +270,10 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+FILECMD = @FILECMD@
FSTRM_CFLAGS = @FSTRM_CFLAGS@
FSTRM_LIBS = @FSTRM_LIBS@
GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
@@ -336,6 +345,8 @@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
+QUICHE_CFLAGS = @QUICHE_CFLAGS@
+QUICHE_LIBS = @QUICHE_LIBS@
RAGEL = @RAGEL@
RANLIB = @RANLIB@
RE2_CFLAGS = @RE2_CFLAGS@
@@ -355,6 +366,8 @@ SYSTEMD_MODULES_LOAD = @SYSTEMD_MODULES_LOAD@
THREADFLAGS = @THREADFLAGS@
VERSION = @VERSION@
WARN_CFLAGS = @WARN_CFLAGS@
+XDP_CFLAGS = @XDP_CFLAGS@
+XDP_LIBS = @XDP_LIBS@
YAHTTP_CFLAGS = @YAHTTP_CFLAGS@
YAHTTP_LIBS = @YAHTTP_LIBS@
abs_builddir = @abs_builddir@
@@ -557,7 +570,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
diff --git a/ext/yahttp/yahttp/Makefile.in b/ext/yahttp/yahttp/Makefile.in
index ac4f348..a59987f 100644
--- a/ext/yahttp/yahttp/Makefile.in
+++ b/ext/yahttp/yahttp/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -97,6 +97,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_pthread_set_name.m4 \
$(top_srcdir)/m4/ax_python_module.m4 $(top_srcdir)/m4/boost.m4 \
$(top_srcdir)/m4/dnsdist_enable_dnscrypt.m4 \
$(top_srcdir)/m4/dnsdist_enable_doh.m4 \
+ $(top_srcdir)/m4/dnsdist_enable_doh3.m4 \
+ $(top_srcdir)/m4/dnsdist_enable_doq.m4 \
$(top_srcdir)/m4/dnsdist_enable_tls_providers.m4 \
$(top_srcdir)/m4/dnsdist_with_cdb.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -116,6 +118,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_pthread_set_name.m4 \
$(top_srcdir)/m4/pdns_check_ragel.m4 \
$(top_srcdir)/m4/pdns_check_secure_memset.m4 \
$(top_srcdir)/m4/pdns_d_fortify_source.m4 \
+ $(top_srcdir)/m4/pdns_enable_coverage.m4 \
+ $(top_srcdir)/m4/pdns_enable_fuzz_targets.m4 \
$(top_srcdir)/m4/pdns_enable_ipcipher.m4 \
$(top_srcdir)/m4/pdns_enable_lto.m4 \
$(top_srcdir)/m4/pdns_enable_sanitizers.m4 \
@@ -133,10 +137,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_pthread_set_name.m4 \
$(top_srcdir)/m4/pdns_with_lua.m4 \
$(top_srcdir)/m4/pdns_with_net_snmp.m4 \
$(top_srcdir)/m4/pdns_with_nghttp2.m4 \
+ $(top_srcdir)/m4/pdns_with_quiche.m4 \
$(top_srcdir)/m4/pdns_with_re2.m4 \
$(top_srcdir)/m4/pdns_with_service_user.m4 \
- $(top_srcdir)/m4/systemd.m4 $(top_srcdir)/m4/warnings.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/pdns_with_xsk.m4 $(top_srcdir)/m4/systemd.m4 \
+ $(top_srcdir)/m4/warnings.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -229,8 +234,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@@ -238,6 +241,7 @@ AMTAR = @AMTAR@
AM_CPPFLAGS = @AM_CPPFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
+ARC4RANDOM_LIBS = @ARC4RANDOM_LIBS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -248,13 +252,16 @@ BOOST_ROOT = @BOOST_ROOT@
BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS = @BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS@
BOOST_UNIT_TEST_FRAMEWORK_LDPATH = @BOOST_UNIT_TEST_FRAMEWORK_LDPATH@
BOOST_UNIT_TEST_FRAMEWORK_LIBS = @BOOST_UNIT_TEST_FRAMEWORK_LIBS@
+BPF_CFLAGS = @BPF_CFLAGS@
+BPF_LIBS = @BPF_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CDB_CFLAGS = @CDB_CFLAGS@
CDB_LIBS = @CDB_LIBS@
CFLAGS = @CFLAGS@
-CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -271,8 +278,10 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+FILECMD = @FILECMD@
FSTRM_CFLAGS = @FSTRM_CFLAGS@
FSTRM_LIBS = @FSTRM_LIBS@
GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
@@ -344,6 +353,8 @@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
+QUICHE_CFLAGS = @QUICHE_CFLAGS@
+QUICHE_LIBS = @QUICHE_LIBS@
RAGEL = @RAGEL@
RANLIB = @RANLIB@
RE2_CFLAGS = @RE2_CFLAGS@
@@ -363,6 +374,8 @@ SYSTEMD_MODULES_LOAD = @SYSTEMD_MODULES_LOAD@
THREADFLAGS = @THREADFLAGS@
VERSION = @VERSION@
WARN_CFLAGS = @WARN_CFLAGS@
+XDP_CFLAGS = @XDP_CFLAGS@
+XDP_LIBS = @XDP_LIBS@
YAHTTP_CFLAGS = @YAHTTP_CFLAGS@
YAHTTP_LIBS = @YAHTTP_LIBS@
abs_builddir = @abs_builddir@
@@ -583,7 +596,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
diff --git a/ext/yahttp/yahttp/cookie.hpp b/ext/yahttp/yahttp/cookie.hpp
index aa5359b..9e50d8b 100644
--- a/ext/yahttp/yahttp/cookie.hpp
+++ b/ext/yahttp/yahttp/cookie.hpp
@@ -118,7 +118,7 @@ namespace YaHTTP {
if (s.find("=") != std::string::npos)
keyValuePair(s, k, v);
else
- k = s;
+ k = std::move(s);
if (k == "expires") {
DateTime dt;
dt.parseCookie(v);
diff --git a/ext/yahttp/yahttp/reqresp.cpp b/ext/yahttp/yahttp/reqresp.cpp
index e5f9c95..a96def6 100644
--- a/ext/yahttp/yahttp/reqresp.cpp
+++ b/ext/yahttp/yahttp/reqresp.cpp
@@ -136,7 +136,7 @@ namespace YaHTTP {
if (target->headers.find(key) != target->headers.end()) {
target->headers[key] = target->headers[key] + ";" + value;
} else {
- target->headers[key] = value;
+ target->headers[key] = std::move(value);
}
}
}
diff --git a/ext/yahttp/yahttp/router.cpp b/ext/yahttp/yahttp/router.cpp
index 18ea9b6..e123b38 100644
--- a/ext/yahttp/yahttp/router.cpp
+++ b/ext/yahttp/yahttp/router.cpp
@@ -5,8 +5,6 @@
#include "router.hpp"
namespace YaHTTP {
- typedef funcptr::tuple<int,int> TDelim;
-
// router is defined here.
YaHTTP::Router Router::router;
@@ -24,76 +22,108 @@ namespace YaHTTP {
routes.push_back(funcptr::make_tuple(method2, url, handler, name));
};
- bool Router::route(Request *req, THandlerFunction& handler) {
- std::map<std::string, TDelim> params;
- int pos1,pos2;
- bool matched = false;
- std::string rname;
-
- // iterate routes
- for(TRouteList::iterator i = routes.begin(); !matched && i != routes.end(); i++) {
- int k1,k2,k3;
- std::string pname;
- std::string method, url;
- funcptr::tie(method, url, handler, rname) = *i;
-
- if (method.empty() == false && req->method != method) continue; // no match on method
- // see if we can't match the url
- params.clear();
- // simple matcher func
- for(k1=0, k2=0; k1 < static_cast<int>(url.size()) && k2 < static_cast<int>(req->url.path.size()); ) {
- if (url[k1] == '<') {
- pos1 = k2;
- k3 = k1+1;
+ bool Router::match(const std::string& route, const URL& requrl, std::map<std::string, TDelim> &params) {
+ size_t rpos = 0;
+ size_t upos = 0;
+ size_t npos = 0;
+ size_t nstart = 0;
+ size_t nend = 0;
+ std::string pname;
+ for(; rpos < route.size() && upos < requrl.path.size(); ) {
+ if (route[rpos] == '<') {
+ nstart = upos;
+ npos = rpos+1;
// start of parameter
- while(k1 < static_cast<int>(url.size()) && url[k1] != '>') k1++;
- pname = std::string(url.begin()+k3, url.begin()+k1);
+ while(rpos < route.size() && route[rpos] != '>') {
+ rpos++;
+ }
+ pname = std::string(route.begin()+static_cast<long>(npos), route.begin()+static_cast<long>(rpos));
// then we also look it on the url
- if (pname[0]=='*') {
+ if (pname[0] == '*') {
pname = pname.substr(1);
// this matches whatever comes after it, basically end of string
- pos2 = req->url.path.size();
- if (pname != "")
- params[pname] = funcptr::tie(pos1,pos2);
- k1 = url.size();
- k2 = req->url.path.size();
+ nend = requrl.path.size();
+ if (!pname.empty()) {
+ params[pname] = funcptr::tie(nstart,nend);
+ }
+ rpos = route.size();
+ upos = requrl.path.size();
break;
} else {
- // match until url[k1]
- while(k2 < static_cast<int>(req->url.path.size()) && req->url.path[k2] != url[k1+1]) k2++;
- pos2 = k2;
- params[pname] = funcptr::tie(pos1,pos2);
+ // match until url[upos] or next / if pattern is at end
+ while (upos < requrl.path.size()) {
+ if (route[rpos+1] == '\0' && requrl.path[upos] == '/') {
+ break;
+ }
+ if (requrl.path[upos] == route[rpos+1]) {
+ break;
+ }
+ upos++;
+ }
+ nend = upos;
+ params[pname] = funcptr::tie(nstart, nend);
}
- k2--;
+ upos--;
}
- else if (url[k1] != req->url.path[k2]) {
+ else if (route[rpos] != requrl.path[upos]) {
break;
}
- k1++; k2++;
+ rpos++; upos++;
+ }
+ return route[rpos] == requrl.path[upos];
+ }
+
+ RoutingResult Router::route(Request *req, THandlerFunction& handler) {
+ std::map<std::string, TDelim> params;
+ bool matched = false;
+ bool seen = false;
+ std::string rname;
+
+ // iterate routes
+ for (auto& route: routes) {
+ std::string method;
+ std::string url;
+ funcptr::tie(method, url, handler, rname) = route;
+
+ // see if we can't match the url
+ params.clear();
+ // simple matcher func
+ matched = match(url, req->url, params);
+
+ if (matched && !method.empty() && req->method != method) {
+ // method did not match, record it though so we can return correct result
+ matched = false;
+ seen = true;
+ continue;
}
+ if (matched) {
+ break;
+ }
+ }
- // ensure.
- if (url[k1] != req->url.path[k2])
- matched = false;
- else
- matched = true;
+ if (!matched) {
+ if (seen) {
+ return RouteNoMethod;
+ }
+ // no route
+ return RouteNotFound;
}
- if (!matched) { return false; } // no route
- req->parameters.clear();
+ req->parameters.clear();
- for(std::map<std::string, TDelim>::iterator i = params.begin(); i != params.end(); i++) {
- int p1,p2;
- funcptr::tie(p1,p2) = i->second;
- std::string value(req->url.path.begin() + p1, req->url.path.begin() + p2);
+ for (const auto& param: params) {
+ int nstart = 0;
+ int nend = 0;
+ funcptr::tie(nstart, nend) = param.second;
+ std::string value(req->url.path.begin() + nstart, req->url.path.begin() + nend);
value = Utility::decodeURL(value);
- req->parameters[i->first] = value;
+ req->parameters[param.first] = std::move(value);
}
- req->routeName = rname;
+ req->routeName = std::move(rname);
- return true;
+ return RouteFound;
};
void Router::printRoutes(std::ostream &os) {
diff --git a/ext/yahttp/yahttp/router.hpp b/ext/yahttp/yahttp/router.hpp
index 205119c..3cb13ed 100644
--- a/ext/yahttp/yahttp/router.hpp
+++ b/ext/yahttp/yahttp/router.hpp
@@ -25,9 +25,16 @@ namespace funcptr = boost;
#include <utility>
namespace YaHTTP {
+ enum RoutingResult {
+ RouteFound = 1,
+ RouteNotFound = 0,
+ RouteNoMethod = -1,
+ };
+
typedef funcptr::function <void(Request* req, Response* resp)> THandlerFunction; //!< Handler function pointer
typedef funcptr::tuple<std::string, std::string, THandlerFunction, std::string> TRoute; //!< Route tuple (method, urlmask, handler, name)
typedef std::vector<TRoute> TRouteList; //!< List of routes in order of evaluation
+ typedef funcptr::tuple<int,int> TDelim;
/*! Implements simple router.
@@ -44,26 +51,28 @@ is consumed but not stored. Note that only path is matched, scheme, host and url
static Router router; //<! Singleton instance of Router
public:
void map(const std::string& method, const std::string& url, THandlerFunction handler, const std::string& name); //<! Instance method for mapping urls
- bool route(Request *req, THandlerFunction& handler); //<! Instance method for performing routing
+ RoutingResult route(Request *req, THandlerFunction& handler); //<! Instance method for performing routing
void printRoutes(std::ostream &os); //<! Instance method for printing routes
std::pair<std::string, std::string> urlFor(const std::string &name, const strstr_map_t& arguments); //<! Instance method for generating paths
+ static bool match(const std::string& route, const URL& requrl, std::map<std::string, TDelim>& params); //<! Instance method for matching a route
/*! Map an URL.
-If method is left empty, it will match any method. Name is also optional, but needed if you want to find it for making URLs
+If method is left empty, it will match any method. Name is also optional, but needed if you want to find it for making URLs
*/
- static void Map(const std::string& method, const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map(method, url, handler, name); };
- static void Get(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("GET", url, handler, name); }; //<! Helper for mapping GET
- static void Post(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("POST", url, handler, name); }; //<! Helper for mapping POST
- static void Put(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("PUT", url, handler, name); }; //<! Helper for mapping PUT
- static void Patch(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("PATCH", url, handler, name); }; //<! Helper for mapping PATCH
- static void Delete(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("DELETE", url, handler, name); }; //<! Helper for mapping DELETE
- static void Any(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("", url, handler, name); }; //<! Helper for mapping any method
+ static void Map(const std::string& method, const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map(method, url, std::move(handler), name); };
+ static void Get(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("GET", url, std::move(handler), name); }; //<! Helper for mapping GET
+ static void Post(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("POST", url, std::move(handler), name); }; //<! Helper for mapping POST
+ static void Put(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("PUT", url, std::move(handler), name); }; //<! Helper for mapping PUT
+ static void Patch(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("PATCH", url, std::move(handler), name); }; //<! Helper for mapping PATCH
+ static void Delete(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("DELETE", url, std::move(handler), name); }; //<! Helper for mapping DELETE
+ static void Any(const std::string& url, THandlerFunction handler, const std::string& name = "") { router.map("", url, std::move(handler), name); }; //<! Helper for mapping any method
- static bool Route(Request *req, THandlerFunction& handler) { return router.route(req, handler); }; //<! Performs routing based on req->url.path
+ static bool Match(const std::string& route, const URL& requrl, std::map<std::string, TDelim>& params) { return router.match(route, requrl, params); };
+ static RoutingResult Route(Request *req, THandlerFunction& handler) { return router.route(req, handler); }; //<! Performs routing based on req->url.path, returns RouteFound if route is found and method matches, RouteNoMethod if route is seen but method did match, and RouteNotFound if not found.
static void PrintRoutes(std::ostream &os) { router.printRoutes(os); }; //<! Prints all known routes to given output stream
static std::pair<std::string, std::string> URLFor(const std::string &name, const strstr_map_t& arguments) { return router.urlFor(name,arguments); }; //<! Generates url from named route and arguments. Missing arguments are assumed empty
- static const TRouteList& GetRoutes() { return router.routes; } //<! Reference to route list
+ static const TRouteList& GetRoutes() { return router.routes; } //<! Reference to route list
static void Clear() { router.routes.clear(); } //<! Clear all routes
TRouteList routes; //<! Instance variable for routes
diff --git a/ext/yahttp/yahttp/utility.hpp b/ext/yahttp/yahttp/utility.hpp
index 23e6b8a..1d5e41e 100644
--- a/ext/yahttp/yahttp/utility.hpp
+++ b/ext/yahttp/yahttp/utility.hpp
@@ -392,7 +392,7 @@ namespace YaHTTP {
}
key = decodeURL(key);
value = decodeURL(value);
- parameter_map[key] = value;
+ parameter_map[key] = std::move(value);
if (nextpos == std::string::npos) {
// no more parameters left
break;