request_dispatcher.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLUGINS_WEBVIEW_REQUEST_DISPATCHER_H_
00024 #define __PLUGINS_WEBVIEW_REQUEST_DISPATCHER_H_
00025
00026 #include <string>
00027 #include <map>
00028 #include <stdint.h>
00029
00030 struct MHD_Connection;
00031 class WebRequestProcessor;
00032 class StaticWebReply;
00033
00034 namespace fawkes {
00035 class CacheLogger;
00036 }
00037
00038 class WebRequestDispatcher
00039 {
00040 public:
00041 void add_processor(const char *url_prefix, WebRequestProcessor *processor);
00042 void remove_processor(const char *url_prefix);
00043
00044
00045 static int process_request_cb(void *callback_data,
00046 struct MHD_Connection * connection,
00047 const char *url,
00048 const char *method,
00049 const char *version,
00050 const char *upload_data,
00051 size_t *upload_data_size,
00052 void **session_data);
00053
00054 static int dynamic_reply_data_cb(void *reply, uint64_t pos, char *buf, int max);
00055 static void dynamic_reply_free_cb(void *reply);
00056
00057 int queue_static_reply(struct MHD_Connection * connection,
00058 StaticWebReply *sreply);
00059 int process_request(struct MHD_Connection * connection,
00060 const char *url,
00061 const char *method,
00062 const char *version,
00063 const char *upload_data,
00064 size_t *upload_data_size,
00065 void **session_data);
00066
00067 private:
00068 fawkes::CacheLogger *__cache_logger;
00069
00070 std::map<std::string, WebRequestProcessor *> __processors;
00071 WebRequestProcessor *__startpage_processor;
00072 };
00073
00074
00075 #endif