From b1cc0d05e799a551326da3b8376aaff8f374b9d9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 16 Apr 2018 21:35:11 +0100 Subject: Route Options Provide an irouteOptions constructor that takes new class RouteOptions for finer grained control over the setup process. This currently provides the option to not add the default serializers. --- icespider/core/Jamfile.jam | 2 +- icespider/core/irouteHandler.cpp | 17 +++++++++++++---- icespider/core/irouteHandler.h | 4 ++++ icespider/core/routeOptions.ice | 12 ++++++++++++ icespider/fcgi/Jamfile.jam | 8 ++++++-- icespider/fileSessions/Jamfile.jam | 1 + icespider/unittests/Jamfile.jam | 5 ++++- 7 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 icespider/core/routeOptions.ice diff --git a/icespider/core/Jamfile.jam b/icespider/core/Jamfile.jam index b5712ad..216127e 100644 --- a/icespider/core/Jamfile.jam +++ b/icespider/core/Jamfile.jam @@ -4,7 +4,7 @@ lib boost_system ; lib boost_filesystem ; lib icespider-core : - [ glob-tree *.c *.cpp : bin ] + [ glob-tree *.c *.cpp *.ice : bin ] : ../common//icespider-common adhocutil diff --git a/icespider/core/irouteHandler.cpp b/icespider/core/irouteHandler.cpp index 348ac8e..d4ad722 100644 --- a/icespider/core/irouteHandler.cpp +++ b/icespider/core/irouteHandler.cpp @@ -5,14 +5,23 @@ INSTANTIATEFACTORY(IceSpider::IRouteHandler, const IceSpider::Core *); namespace IceSpider { + const RouteOptions IRouteHandler::defaultRouteOptions { + }; IRouteHandler::IRouteHandler(HttpMethod m, const std::string & p) : + IRouteHandler(m, p, defaultRouteOptions) + { + } + + IRouteHandler::IRouteHandler(HttpMethod m, const std::string & p, const RouteOptions & ro) : Path(p), method(m) { - auto globalSerializers = AdHoc::PluginManager::getDefault()->getAll(); - for (const auto & gs : globalSerializers) { - auto slash = gs->name.find('/'); - routeSerializers.insert({ { gs->name.substr(0, slash), gs->name.substr(slash + 1) }, gs->implementation() }); + if (ro.addDefaultSerializers) { + auto globalSerializers = AdHoc::PluginManager::getDefault()->getAll(); + for (const auto & gs : globalSerializers) { + auto slash = gs->name.find('/'); + routeSerializers.insert({ { gs->name.substr(0, slash), gs->name.substr(slash + 1) }, gs->implementation() }); + } } } diff --git a/icespider/core/irouteHandler.h b/icespider/core/irouteHandler.h index 38bc1ed..4fbb581 100644 --- a/icespider/core/irouteHandler.h +++ b/icespider/core/irouteHandler.h @@ -7,13 +7,17 @@ #include #include #include +#include "routeOptions.h" namespace IceSpider { class Core; class DLL_PUBLIC IRouteHandler : public Path { public: + const static RouteOptions defaultRouteOptions; + IRouteHandler(HttpMethod, const std::string & path); + IRouteHandler(HttpMethod, const std::string & path, const RouteOptions &); virtual ~IRouteHandler(); virtual void execute(IHttpRequest * request) const = 0; diff --git a/icespider/core/routeOptions.ice b/icespider/core/routeOptions.ice new file mode 100644 index 0000000..13279bb --- /dev/null +++ b/icespider/core/routeOptions.ice @@ -0,0 +1,12 @@ +#ifndef ICESPIDER_ROUTEOPTIONS_ICE +#define ICESPIDER_ROUTEOPTIONS_ICE + +[["ice-prefix"]] +module IceSpider { + local class RouteOptions { + bool addDefaultSerializers = true; + }; +}; + +#endif + diff --git a/icespider/fcgi/Jamfile.jam b/icespider/fcgi/Jamfile.jam index 9183820..47c10fa 100644 --- a/icespider/fcgi/Jamfile.jam +++ b/icespider/fcgi/Jamfile.jam @@ -1,12 +1,16 @@ +lib slicer ; lib fcgi : : fcgi ; lib fcgi++ : : fcgi++ ; lib icespider-fcgi : [ glob-tree *.cpp : bin ] : + slicer fcgi fcgi++ - ..//core + ..//core//icespider-core + ../core//icespider-core : : - ..//core + ..//core//icespider-core + ../core//icespider-core ; diff --git a/icespider/fileSessions/Jamfile.jam b/icespider/fileSessions/Jamfile.jam index f08559d..1a457cd 100644 --- a/icespider/fileSessions/Jamfile.jam +++ b/icespider/fileSessions/Jamfile.jam @@ -9,5 +9,6 @@ lib icespider-filesessions : boost_filesystem adhocutil ../core//icespider-core + ../core//icespider-core ; diff --git a/icespider/unittests/Jamfile.jam b/icespider/unittests/Jamfile.jam index af8041c..aa8d879 100644 --- a/icespider/unittests/Jamfile.jam +++ b/icespider/unittests/Jamfile.jam @@ -50,11 +50,11 @@ run slicer-xml ../xslt//icespider-xslt ../core//icespider-core + ../core//icespider-core ../compile//icespider-compile ../compile//icespider-compile . test-api - ../core : testCompile : ; @@ -76,6 +76,7 @@ run slicer-xml ../common//icespider-common ../core//icespider-core + ../core//icespider-core ../xslt//icespider-xslt ../testing//icespider-testing ../common//icespider-common @@ -94,6 +95,7 @@ run testCommon ../common//icespider-common ../core//icespider-core + ../core//icespider-core boost_system boost_filesystem slicer @@ -114,6 +116,7 @@ run boost_system boost_filesystem ../core//icespider-core + ../core//icespider-core ; lib test-api : -- cgit v1.2.3