diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-09-01 00:29:59 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-09-01 00:29:59 +0100 |
commit | ec7e4590b01c7a28ecb8d0f3c98897b63841f4e5 (patch) | |
tree | 8cd126f9707e309e585824e5c5ea707a9c8a53fa | |
parent | Get HTTP method from env (diff) | |
download | icespider-ec7e4590b01c7a28ecb8d0f3c98897b63841f4e5.tar.bz2 icespider-ec7e4590b01c7a28ecb8d0f3c98897b63841f4e5.tar.xz icespider-ec7e4590b01c7a28ecb8d0f3c98897b63841f4e5.zip |
Pass current Core instance to route handlers
-rw-r--r-- | icespider/compile/routeCompiler.cpp | 2 | ||||
-rw-r--r-- | icespider/core/core.cpp | 2 | ||||
-rw-r--r-- | icespider/core/irouteHandler.cpp | 2 | ||||
-rw-r--r-- | icespider/core/irouteHandler.h | 4 |
4 files changed, 6 insertions, 4 deletions
diff --git a/icespider/compile/routeCompiler.cpp b/icespider/compile/routeCompiler.cpp index e2ab8a1..99771aa 100644 --- a/icespider/compile/routeCompiler.cpp +++ b/icespider/compile/routeCompiler.cpp @@ -294,7 +294,7 @@ namespace IceSpider { fprintbf(1, output, "// path: %s\n", r->path); fprintbf(1, output, "class %s : public IceSpider::IRouteHandler {\n", r->name); fprintbf(2, output, "public:\n"); - fprintbf(3, output, "%s() :\n", r->name); + fprintbf(3, output, "%s(const IceSpider::Core *) :\n", r->name); fprintbf(4, output, "IceSpider::IRouteHandler(IceSpider::HttpMethod::%s, \"%s\")", methodName, r->path); for (const auto & p : r->params) { if (p->hasUserSource) { diff --git a/icespider/core/core.cpp b/icespider/core/core.cpp index cb0c671..6a44523 100644 --- a/icespider/core/core.cpp +++ b/icespider/core/core.cpp @@ -11,7 +11,7 @@ namespace IceSpider { routes.resize(HttpMethod::OPTIONS + 1, {{ }}); // Initialize routes for (const auto & rp : AdHoc::PluginManager::getDefault()->getAll<RouteHandlerFactory>()) { - auto r = rp->implementation()->create(); + auto r = rp->implementation()->create(this); auto & mroutes = routes[r->method]; if (mroutes.size() <= r->pathElementCount()) { mroutes.resize(r->pathElementCount() + 1); diff --git a/icespider/core/irouteHandler.cpp b/icespider/core/irouteHandler.cpp index 172c77d..ca9cb94 100644 --- a/icespider/core/irouteHandler.cpp +++ b/icespider/core/irouteHandler.cpp @@ -2,7 +2,7 @@ #include "core.h" #include <factory.impl.h> -INSTANTIATEVOIDFACTORY(IceSpider::IRouteHandler); +INSTANTIATEFACTORY(IceSpider::IRouteHandler, const IceSpider::Core *); namespace IceSpider { IRouteHandler::IRouteHandler(HttpMethod m, const std::string & p) : diff --git a/icespider/core/irouteHandler.h b/icespider/core/irouteHandler.h index 4832bdb..ffbde36 100644 --- a/icespider/core/irouteHandler.h +++ b/icespider/core/irouteHandler.h @@ -10,6 +10,8 @@ #include <boost/lexical_cast.hpp> namespace IceSpider { + class Core; + class DLL_PUBLIC IRouteHandler : public Path { public: IRouteHandler(HttpMethod, const std::string & path); @@ -44,7 +46,7 @@ namespace IceSpider { void addRouteSerializer(const MimeType &, StreamSerializerFactoryPtr); void removeRouteSerializer(const MimeType &); }; - typedef AdHoc::Factory<IRouteHandler> RouteHandlerFactory; + typedef AdHoc::Factory<IRouteHandler, const Core *> RouteHandlerFactory; } #endif |