summaryrefslogtreecommitdiffhomepage
path: root/plugins
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-04-09 18:30:32 +0200
committerRoland Reichwein <mail@reichwein.it>2020-04-09 18:30:32 +0200
commit0d157fb407a35f8afe6d6f0f4c2cc5cd5d5a1933 (patch)
tree86ccea82ebbe29197eacb9a85e8ec7548c5ae38c /plugins
parent2f42619303627db401e469e2fd65123cd794a378 (diff)
Prepared generate_page for static-files plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/static-files/static-files.cpp12
-rw-r--r--plugins/static-files/static-files.h8
2 files changed, 17 insertions, 3 deletions
diff --git a/plugins/static-files/static-files.cpp b/plugins/static-files/static-files.cpp
index 287c975..358e239 100644
--- a/plugins/static-files/static-files.cpp
+++ b/plugins/static-files/static-files.cpp
@@ -19,8 +19,16 @@ static_files_plugin::~static_files_plugin()
//std::cout << "Plugin destructor" << std::endl;
}
-std::string static_files_plugin::generate_page(std::string path)
+std::string static_files_plugin::generate_page(
+ std::function<std::string(const std::string& key)>& GetServerParam,
+ std::function<std::string(const std::string& key)>& GetRequestParam, // request including body (POST...)
+ std::function<void(const std::string& key, const std::string& value)>& SetResponseHeader // to be added to result string
+)
{
- return "Static Files "s + path;
+ try {
+ return "Static Files "s + GetServerParam("path"s);
+ } catch (const std::exception& ex) {
+ return "Error: "s + ex.what();
+ }
}
diff --git a/plugins/static-files/static-files.h b/plugins/static-files/static-files.h
index 7ea5500..ff35e92 100644
--- a/plugins/static-files/static-files.h
+++ b/plugins/static-files/static-files.h
@@ -7,8 +7,14 @@ class static_files_plugin: public webserver_plugin_interface
public:
static_files_plugin();
~static_files_plugin();
+
std::string name();
- std::string generate_page(std::string path);
+ std::string generate_page(
+ std::function<std::string(const std::string& key)>& GetServerParam,
+ std::function<std::string(const std::string& key)>& GetRequestParam, // request including body (POST...)
+ std::function<void(const std::string& key, const std::string& value)>& SetResponseHeader // to be added to result string
+ );
+
};
extern "C" BOOST_SYMBOL_EXPORT static_files_plugin webserver_plugin;