summaryrefslogtreecommitdiffhomepage
path: root/plugin_interface.h
blob: 13e5f53ecaad2d78b606a28e7993922f0bef26df (plain)
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
#pragma once

#include <boost/config.hpp>

#include <string>
#include <functional>

typedef std::string(plugin_interface_getter_type)(const std::string& key);
typedef void(plugin_interface_setter_type)(const std::string& key, const std::string& value);

class BOOST_SYMBOL_VISIBLE webserver_plugin_interface {
public:
 static const int interface_version {1};
 virtual int version() { return interface_version; }
 
 //
 // The Interface to be implemented by plugins
 //
 
 virtual std::string name() = 0;

 // returns result page without headers
 virtual 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
 ) = 0;

 // Plugin provides own authentication mechanism? Otherwise, webserver makes HTTP AUTH via status 401
 virtual bool has_own_authentication() = 0;

 virtual ~webserver_plugin_interface(){} // optional
};