-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.cpp
31 lines (24 loc) · 821 Bytes
/
router.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "router.h"
namespace graft {
R3Node *Router::m_node = nullptr;
}//namespace graft
/*
int main()
{
Router router1("/root1");
Router router2("/root2");
std::vector<std::pair<std::string, std::string>> vars;
router1.addRoute("/r{id:\\d+}", METHOD_GET, test);
router1.addRoute("/aaa/{s1}/bbb/{s2}", METHOD_GET, test);
router2.addRoute("/rr{id:\\d+}", METHOD_GET, test);
router2.addRoute("/aaaaaa/{s1}/bbbbbb/{s2}", METHOD_GET, test);
if (router1.arm() && router2.arm()) {
bool res = router1.match("/root1/r1", METHOD_GET, vars);
res |= router1.match("/root1/ra", METHOD_GET, vars);
res |= router2.match("/root2/aaaaaa/rr1/bbbbbb/rr2", METHOD_GET, vars);
std::cout << res << std::endl;
for (auto const& p: vars)
std::cout << p.first << ": " << p.second << std::endl;
}
}
*/