23 #include <webview/url_manager.h> 24 #include <webview/request_processor.h> 25 #include <core/threading/mutex.h> 26 #include <core/threading/mutex_locker.h> 27 #include <core/exception.h> 43 WebUrlManager::WebUrlManager()
45 __mutex =
new Mutex();
46 __startpage_processor = NULL;
51 WebUrlManager::~WebUrlManager()
64 WebUrlManager::register_baseurl(
const char *url_prefix,
68 if (std::string(url_prefix) ==
"/") {
69 if (__startpage_processor) {
70 throw Exception(
"Start page processor has already been registered");
72 __startpage_processor = processor;
74 if (__processors.find(url_prefix) != __processors.end()) {
75 throw Exception(
"A processor for %s has already been registered",
78 __processors[url_prefix] = processor;
87 WebUrlManager::unregister_baseurl(
const char *url_prefix)
90 if (std::string(url_prefix) ==
"/") {
91 __startpage_processor = NULL;
93 __processors.erase(url_prefix);
105 WebUrlManager::find_processor(std::string &url)
const 107 if ( url ==
"/" && __startpage_processor ) {
108 return __startpage_processor;
112 std::map<std::string, WebRequestProcessor *>::const_iterator pit;
113 for (pit = __processors.begin();
114 (proc == NULL) && (pit != __processors.end());
117 if (url.find(pit->first) == 0) {
134 WebUrlManager::mutex()
Fawkes library namespace.
Abstract web request processor.
Base class for exceptions in Fawkes.
Mutex mutual exclusion lock.