You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
694 B

#include "HttpManager.h"
#include "Util/StrUtil.h"
HttpManager::HttpManager()
{
}
QMap<QString, QSharedPointer<Controller>> HttpManager::getControllers()
{
if (_controllers.isEmpty()) {
_createController();
}
return _controllers;
}
void HttpManager::registerCtl(const QString &path, const ControllerFunc &fun)
{
QString uri = StrUtil::camelToUri(path);
if (uri.endsWith("/controller")) {
uri = uri.chopped(11);
}
_ctrlFuncs.insert(uri, fun);
}
void HttpManager::_createController()
{
for (const auto &uri : _ctrlFuncs.keys()) {
QSharedPointer<Controller> ctrl(_ctrlFuncs.value(uri)());
_controllers.insert(uri, ctrl);
}
}