本文整理汇总了C++中Router::addRoute方法的典型用法代码示例。如果您正苦于以下问题:C++ Router::addRoute方法的具体用法?C++ Router::addRoute怎么用?C++ Router::addRoute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::addRoute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dummy
TEST_F(RouterTests, test_invalid_registrations) {
Router router;
std::unique_ptr<DummyFactory> dummy(new DummyFactory());
ASSERT_THROW(
router.addRoute("/", std::move(dummy), Router::route_t::EXACT),
RouterException) << "'/' is not allowed.";
}
示例2: DummyFactory
TEST_F(RouterTests, test_valid_registration_route) {
Router router;
std::unique_ptr<DummyFactory> dummy1(new DummyFactory());
router.addRoute("/dummy1",
std::move(dummy1),
Router::route_t::EXACT);
ASSERT_THROW(router.getHandler("/"), RouterException)
<< "No catch all registered, access to '/' impossible";
std::unique_ptr<DummyFactory> dummy2(new DummyFactory());
router.addRoute("/dummy2",
std::move(dummy2),
Router::route_t::CATCH_ALL);
router.getHandler("/dummy1");
router.getHandler("/dummy2");
ASSERT_NE(router.getHandler("/"), nullptr)
<< "A handling factory should be returned";
}