aboutsummaryrefslogtreecommitdiff
path: root/web/module
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-08 13:45:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-14 12:02:13 +0200
commite28ab8f48c891c03cf4b3a8ed88b98d38a561960 (patch)
tree0ae1dbb54e497fc797e5a73fcf3dd2dc487a5572 /web/module
parenta31dfac365feef7838b01b1efd3fe058c89484d7 (diff)
Separate brep module configuration from Apache server configuration
Diffstat (limited to 'web/module')
-rw-r--r--web/module47
1 files changed, 31 insertions, 16 deletions
diff --git a/web/module b/web/module
index 1774884..50cc6be 100644
--- a/web/module
+++ b/web/module
@@ -5,6 +5,7 @@
#ifndef WEB_MODULE
#define WEB_MODULE
+#include <map>
#include <string>
#include <vector>
#include <iosfwd>
@@ -18,6 +19,8 @@
namespace web
{
+ using butl::optional;
+
// HTTP status code.
//
// @@ Define some commonly used constants?
@@ -58,7 +61,10 @@ namespace web
sequence_error (std::string d): std::runtime_error (std::move (d)) {}
};
- using butl::optional;
+ // Map of module configuration option names to the boolean flag indicating
+ // whether the value is expected for the option.
+ //
+ using option_descriptions = std::map<std::string, bool>;
struct name_value
{
@@ -182,27 +188,36 @@ namespace web
class module
{
public:
- // During startup the web server calls this function on the
- // module exemplar passing a list of configuration name-value
- // pairs. The place these configuration pairs come from is
- // implementation-specific (normally a configuration file).
- // Any exception thrown by this function terminates the web
+ // Description of configuration options supported by this module. Note:
+ // should be callable during static initialization.
+ //
+ virtual option_descriptions
+ options () = 0;
+
+ // During startup the web server calls this function on the module
+ // exemplar passing a list of configuration options. The place these
+ // configuration options come from is implementation-specific (normally
+ // a configuration file). The web server guarantees that only options
+ // listed in the map returned by the options() function above can be
+ // present. Any exception thrown by this function terminates the web
// server.
//
virtual void
init (const name_values&, log&) = 0;
- // Any exception other than invalid_request described above that
- // leaves this function is treated by the web server implementation
- // as an internal server error (500). Similar to invalid_request,
- // it will try to return the status and description (obtained by
- // calling what() on std::exception) to the client, if possible.
- // The description is assume to be encoded in UTF-8. The
- // implementation may provide a configuration option to omit
- // the description from the response, for security/privacy
- // reasons.
+ // Return false if decline to handle the request. If handling have been
+ // declined after any unbuffered content has been written, then the
+ // implementation shall terminate the response in a suitable but
+ // unspecified manner. Any exception other than invalid_request described
+ // above that leaves this function is treated by the web server
+ // implementation as an internal server error (500). Similar to
+ // invalid_request, it will try to return the status and description
+ // (obtained by calling what() on std::exception) to the client, if
+ // possible. The description is assume to be encoded in UTF-8. The
+ // implementation may provide a configuration option to omit the
+ // description from the response, for security/privacy reasons.
//
- virtual void
+ virtual bool
handle (request&, response&, log&) = 0;
};
}