Introduce proper HandlerFactory and reduce dependencies of RequestWorker
This commit is contained in:
@@ -3,7 +3,25 @@
|
||||
#include <memory>
|
||||
#include "handler.h"
|
||||
#include "../template.h"
|
||||
class HandlerFactory
|
||||
{
|
||||
HandlerConfig &handlerConfig;
|
||||
Template &templ;
|
||||
Database &db;
|
||||
UrlProvider &urlProvider;
|
||||
ICache &cache;
|
||||
|
||||
template <class T> inline std::unique_ptr<T> produce(Session &userSession)
|
||||
{
|
||||
return std::make_unique<T>(handlerConfig, templ, db, userSession, urlProvider, cache);
|
||||
}
|
||||
|
||||
public:
|
||||
HandlerFactory(HandlerConfig &handlerConfig, Template &templ, Database &db, UrlProvider &urlprovider, ICache &cache)
|
||||
: handlerConfig(handlerConfig), templ(templ), db(db), urlProvider(urlprovider), cache(cache)
|
||||
{
|
||||
}
|
||||
std::unique_ptr<Handler> createHandler(const std::string &action, Session &userSession);
|
||||
};
|
||||
|
||||
std::unique_ptr<Handler> createHandler(const std::string &action, HandlerConfig &handlerConfig, Template &templ,
|
||||
Database &db, Session &usersession, UrlProvider &urlprovider, ICache &cache);
|
||||
#endif // HANDLERFACTORY_H
|
||||
|
Verwijs in nieuw issue
Block a user