diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-06-22 22:45:01 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-06-22 22:45:01 +0100 |
commit | d1a031f1714f8ac437a809f23b988da9346fdf5e (patch) | |
tree | 3225b8586a626b6bb5ca4a99cfc9c070c1ed3ed9 | |
parent | Don't crash when no route found (no 404 handler yet) (diff) | |
download | icespider-d1a031f1714f8ac437a809f23b988da9346fdf5e.tar.bz2 icespider-d1a031f1714f8ac437a809f23b988da9346fdf5e.tar.xz icespider-d1a031f1714f8ac437a809f23b988da9346fdf5e.zip |
An empty set of default routes for all methods
-rw-r--r-- | icespider/core/core.cpp | 4 | ||||
-rw-r--r-- | icespider/unittests/testApp.cpp | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/icespider/core/core.cpp b/icespider/core/core.cpp index 525a99f..ba236ac 100644 --- a/icespider/core/core.cpp +++ b/icespider/core/core.cpp @@ -8,8 +8,8 @@ namespace ba = boost::algorithm; namespace IceSpider { Core::Core() { - // Big enough to map all the request methods - routes.resize(UserIceSpider::HttpMethod::OPTIONS + 1); + // Big enough to map all the request methods (an empty of zero lenght routes as default) + routes.resize(UserIceSpider::HttpMethod::OPTIONS + 1, {{ }}); // Initialize routes for (const auto & rp : AdHoc::PluginManager::getDefault()->getAll<IRouteHandler>()) { auto r = rp->implementation(); diff --git a/icespider/unittests/testApp.cpp b/icespider/unittests/testApp.cpp index e91f618..f79d331 100644 --- a/icespider/unittests/testApp.cpp +++ b/icespider/unittests/testApp.cpp @@ -25,15 +25,15 @@ BOOST_AUTO_TEST_CASE( testCoreSettings ) BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::GET][1].size()); BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::GET][2].size()); BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::GET][3].size()); - BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::HEAD].size()); + BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::HEAD].size()); BOOST_REQUIRE_EQUAL(2, routes[HttpMethod::POST].size()); BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::POST][0].size()); BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::POST][1].size()); - BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::PUT].size()); + BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::PUT].size()); BOOST_REQUIRE_EQUAL(2, routes[HttpMethod::DELETE].size()); BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::DELETE][0].size()); BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::DELETE][1].size()); - BOOST_REQUIRE_EQUAL(0, routes[HttpMethod::OPTIONS].size()); + BOOST_REQUIRE_EQUAL(1, routes[HttpMethod::OPTIONS].size()); } class TestRequest : public IceSpider::IHttpRequest { |