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.
22 lines
662 B
22 lines
662 B
#include "ServiceManager.h"
|
|
#include "HttpManager.h"
|
|
#include <QtConcurrent>
|
|
|
|
ServiceManager::ServiceManager()
|
|
{
|
|
QMap<QString, QSharedPointer<Controller>> _controllers = HttpManager::instance().getControllers();
|
|
for (const auto &uri : _controllers.keys()) {
|
|
QSharedPointer<Controller> controller = _controllers.value(uri);
|
|
_router.Any(uri.toStdString().c_str(), [=](HttpRequest *req, HttpResponse *resp) {
|
|
return controller->service(req, resp);
|
|
});
|
|
}
|
|
}
|
|
|
|
void ServiceManager::run(qint32 port)
|
|
{
|
|
_server.port = port;
|
|
_server.service = &_router;
|
|
QtConcurrent::run([&]() { http_server_run(&_server); });
|
|
}
|