summaryrefslogtreecommitdiff
path: root/src/cgi.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgi.hh')
-rw-r--r--src/cgi.hh42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/cgi.hh b/src/cgi.hh
new file mode 100644
index 0000000..5879694
--- /dev/null
+++ b/src/cgi.hh
@@ -0,0 +1,42 @@
+#ifndef CGI_HH
+#define CGI_HH
+
+#include <functional>
+#include <map>
+#include <string>
+#include <vector>
+
+namespace stuff {
+
+class CGI {
+public:
+ enum request_type {
+ GET,
+ HEAD,
+ POST,
+ PUT,
+ TRACE,
+
+ UNKNOWN,
+ };
+
+ virtual void post_data(std::vector<char>* data) = 0;
+ // Return true if post data is multipart, false otherwise
+ virtual bool post_data(std::map<std::string,std::string>* data) = 0;
+ virtual void query_data(std::map<std::string,std::string>* data) = 0;
+ virtual std::string request_path() = 0;
+ virtual request_type request_type() = 0;
+ virtual std::string content_type() = 0;
+
+ static int run(std::function<bool(CGI*)> handle_request);
+
+protected:
+ CGI() {}
+ virtual ~CGI() {}
+ CGI(const CGI&) = delete;
+ CGI& operator=(const CGI&) = delete;
+};
+
+} // namespace stuff
+
+#endif /* CGI_HH */