aboutsummaryrefslogtreecommitdiff
path: root/brep/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 /brep/module
parenta31dfac365feef7838b01b1efd3fe058c89484d7 (diff)
Separate brep module configuration from Apache server configuration
Diffstat (limited to 'brep/module')
-rw-r--r--brep/module63
1 files changed, 42 insertions, 21 deletions
diff --git a/brep/module b/brep/module
index 295744d..4ac6023 100644
--- a/brep/module
+++ b/brep/module
@@ -9,6 +9,7 @@
#include <brep/types>
#include <brep/utility>
+
#include <brep/options>
#include <brep/diagnostics>
@@ -23,6 +24,7 @@ namespace brep
using web::status_code;
using web::invalid_request;
using web::sequence_error;
+ using web::option_descriptions;
using web::name_value;
using web::name_values;
using web::request;
@@ -94,12 +96,24 @@ namespace brep
module ();
module (const module& );
+ static name_values
+ filter (const name_values&, const option_descriptions&);
+
+ static option_descriptions
+ convert (const cli::options&);
+
+ static void
+ append (option_descriptions& dst, const cli::options& src);
+
+ static void
+ append (option_descriptions& dst, const option_descriptions& src);
+
// Can be used by module implementation to parse HTTP request parameters.
//
- class param_scanner: public cli::scanner
+ class name_value_scanner: public cli::scanner
{
public:
- param_scanner (const name_values&) noexcept;
+ name_value_scanner (const name_values&) noexcept;
virtual bool
more ();
@@ -120,36 +134,43 @@ namespace brep
};
public:
- // Can be called normally by the web server or our custom request
- // dispatching mechanism.
- //
- virtual void
- handle (request&, response&) = 0;
+ virtual const cli::options&
+ cli_options () const = 0;
- bool
- loaded () const noexcept {return loaded_;}
+ virtual void
+ init (cli::scanner&) = 0;
- private:
+ // Can be overriden by custom request dispatcher to initialize sub-modules.
+ //
virtual void
- handle (request&, response&, log&);
+ init (const name_values&);
virtual void
init (const name_values&, log&);
- // Can be overriden by module implementation which has configuration
- // options.
+ virtual bool
+ handle (request&, response&) = 0;
+
+ // web::module interface.
//
- virtual void
- init (cli::scanner& s)
- {
- // Just scan options to ensure there is no misspelled ones.
- //
- options::module o (s, cli::unknown_mode::fail, cli::unknown_mode::fail);
- }
+ public:
+ // Custom request dispatcher can aggregate its own option descriptions with
+ // sub-modules option descriptions. In this case it should still call the
+ // base implementation in order to include the brep::module's options.
+ //
+ virtual option_descriptions
+ options ();
+
+ private:
+ virtual bool
+ handle (request&, response&, log&);
+
+ name_values
+ expand_options (const name_values&);
// Diagnostics implementation details.
//
- private:
+ protected:
log* log_ {nullptr}; // Diagnostics backend provided by the web server.
private: