-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdispatcher.cpp
39 lines (31 loc) · 1.07 KB
/
dispatcher.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <QDebug>
#include <QFileInfo>
#include <QPair>
#include "dispatcher.h"
#include "configuration.h"
Dispatcher::Dispatcher()
{
}
HTTPRequestHandler *Dispatcher::getHTTPRequestHandler(const QString &path) const
{
QStringList urlParts = path.split("/", QString::SkipEmptyParts);
QString urlStart("");
if(!urlParts.empty()){
urlStart = urlParts[0];
}
qDebug() << "urlStart:" << urlStart;
QPair<QString, IPlugin*> pluginInfo;
foreach(QString key, Configuration::getPluginKeys()){
qDebug() << "plugin_key (path):" << key;
if(key.right(key.size()-1) == urlStart || (urlStart == "" && "/" == key)){
pluginInfo = Configuration::getPluginInfo(key);
return pluginInfo.second->getHTTPRequestHandler(Configuration::get(pluginInfo.first).toHash());
}
}
pluginInfo = Configuration::getPluginInfo("static_file");
QPair<QString, IPlugin*> err;
if(err == pluginInfo){
return NULL;
}
return pluginInfo.second->getHTTPRequestHandler(Configuration::get(pluginInfo.first).toHash());
}