aboutsummaryrefslogtreecommitdiff
path: root/brep/module
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-23 12:43:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-23 12:43:52 +0200
commita20443c285dabdec8d2ee740500c62e31ad90c7b (patch)
treeb18db4007e45f8db1f97c0d5abf78729138406ac /brep/module
parent370e361db628f60bca5509dcc354014569d56752 (diff)
Implement apache service
Diffstat (limited to 'brep/module')
-rw-r--r--brep/module27
1 files changed, 11 insertions, 16 deletions
diff --git a/brep/module b/brep/module
index 3f7b409..d976559 100644
--- a/brep/module
+++ b/brep/module
@@ -5,7 +5,9 @@
#ifndef BREP_MODULE
#define BREP_MODULE
+#include <string>
#include <utility> // move()
+#include <cstdint>
#include <web/module>
@@ -20,28 +22,14 @@ namespace brep
// web::module and our module. Or maybe not, need to try.
//
using web::status_code;
+ using web::invalid_request;
+ using web::sequence_error;
using web::name_value;
using web::name_values;
using web::request;
using web::response;
using web::log;
- // This exception is used to signal that the request is invalid
- // (4XX codes) rather than that it could not be processed (5XX).
- // By default 422 is returned, which means the request was
- // semantically invalid.
- //
- struct invalid_request
- {
- status_code status {422};
- std::string description;
-
- //@@ Maybe optional "try again" link?
- //
- invalid_request (std::string d, status_code s = 422)
- : status (s), description (std::move (d)) {}
- };
-
// And this exception indicated a server error (5XX). In particular,
// it is thrown by the fail diagnostics stream and is caught by the
// module implementation where it is both logged as an error and
@@ -105,6 +93,7 @@ namespace brep
//
protected:
module ();
+ module (const module& );
virtual void
handle (request&, response&, log&);
@@ -114,6 +103,12 @@ namespace brep
private:
log* log_ {nullptr}; // Diagnostics backend provided by the web server.
+ // Extract function name from a __PRETTY_FUNCTION__.
+ // Throw std::invalid_argument if fail to parse.
+ //
+ static std::string
+ func_name (const std::string& pretty_name);
+
void
log_write (diag_data&&) const;