aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brep/diagnostics4
-rw-r--r--brep/diagnostics.cxx2
-rw-r--r--brep/module24
-rw-r--r--brep/module.cxx3
-rw-r--r--brep/search.cxx4
-rw-r--r--services.cxx8
-rw-r--r--web/apache/service2
7 files changed, 28 insertions, 19 deletions
diff --git a/brep/diagnostics b/brep/diagnostics
index 70ddb2a..094a62b 100644
--- a/brep/diagnostics
+++ b/brep/diagnostics
@@ -233,7 +233,7 @@ namespace brep
const diag_epilogue& e,
const char* name = nullptr,
const void* data = nullptr)
- : sev_ (s), epilogue (e), name_ (name), data_ (data) {}
+ : sev_ (s), epilogue_ (e), name_ (name), data_ (data) {}
simple_prologue
operator() () const
@@ -289,7 +289,7 @@ namespace brep
operator() (const L& l) const
{
return location_prologue (
- epilogue_, severity::error, name, get_location (l, data_));
+ epilogue_, severity::error, name_, get_location (l, data_));
}
static void
diff --git a/brep/diagnostics.cxx b/brep/diagnostics.cxx
index 5ab34b6..36d409f 100644
--- a/brep/diagnostics.cxx
+++ b/brep/diagnostics.cxx
@@ -9,7 +9,7 @@
using namespace std;
-namespace build
+namespace brep
{
diag_record::
~diag_record () noexcept(false)
diff --git a/brep/module b/brep/module
index dfcf7ad..f6144f2 100644
--- a/brep/module
+++ b/brep/module
@@ -6,6 +6,7 @@
#define BREP_MODULE
#include <brep/diagnostics>
+#include <web/module>
namespace brep
{
@@ -21,6 +22,8 @@ namespace brep
//@@ Maybe optional "try again" link?
//
+ invalid_request (const char* d, web::status_code s = 422)
+ : status (s), description (d) {}
};
// And this exception indicated a server error (5XX). In particular,
@@ -31,6 +34,8 @@ namespace brep
struct server_error
{
diag_data data;
+
+ server_error (diag_data&& d) : data (std::move (d)) {}
};
// Every module member function that needs to produce any diagnostics
@@ -46,7 +51,7 @@ namespace brep
const basic_mark error (severity::error, \
this->log_writer_, \
__PRETTY_FUNCTION__); \
- const basic_mark warn (severity::warn, \
+ const basic_mark warn (severity::warning, \
this->log_writer_, \
__PRETTY_FUNCTION__); \
const basic_mark info (severity::info, \
@@ -65,11 +70,13 @@ namespace brep
// There will, however, most likely be a conflict between
// web::module and our module. Or maybe not, need to try.
//
- using status_code;
- using name_value;
- using name_values;
- using request;
- using response;
+
+ using web::status_code;
+ using web::name_value;
+ using web::name_values;
+ using web::request;
+ using web::response;
+ using web::log;
class module: public web::module
{
@@ -90,8 +97,8 @@ namespace brep
//
std::uint16_t verb_ {0};
- template <class F> static void level1 (const F& f) {if (verb_ >= 1) f ();}
- template <class F> static void level2 (const F& f) {if (verb_ >= 2) f ();}
+ template <class F> void level1 (const F& f) const {if (verb_ >= 1) f ();}
+ template <class F> void level2 (const F& f) const {if (verb_ >= 2) f ();}
// Implementation details.
//
@@ -109,6 +116,7 @@ namespace brep
void
log_write (diag_data&&) const;
+ protected:
const diag_epilogue log_writer_;
};
}
diff --git a/brep/module.cxx b/brep/module.cxx
index 3420aa0..8a9d71a 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -7,6 +7,7 @@
#include <functional> // bind()
using namespace std;
+using namespace placeholders;
namespace brep
{
@@ -26,7 +27,7 @@ namespace brep
//
rs.content (e.status, "text/html;charset=utf-8") << e.description;
}
- catch (const server_error& e)
+ catch (server_error& e)
{
// @@ Both log and return as 505.
//
diff --git a/brep/search.cxx b/brep/search.cxx
index cc3cee2..683016c 100644
--- a/brep/search.cxx
+++ b/brep/search.cxx
@@ -21,10 +21,10 @@ namespace brep
throw invalid_request ("search parameters expected");
if (ps.size () > 100)
- fail << "too many parameters: " < ps.size () <<
+ fail << "too many parameters: " << ps.size () <<
info << "are you crazy to specify so many?";
- info << "handling search request from " << rq.client_ip ();
+ info << "handling search request from "; // << rq.client_ip ();
level2 ([&]{trace << "search request with " << ps.size () << " params";});
diff --git a/services.cxx b/services.cxx
index 2da5bca..2345114 100644
--- a/services.cxx
+++ b/services.cxx
@@ -5,13 +5,13 @@
#include <web/apache/service>
#include <brep/search>
-#include <brep/view>
+//#include <brep/view>
using namespace brep;
using web::apache::service;
static const search search_mod;
-service AP_MODULE_DECLARE_DATA search_srv ("search", search_mod);
+service /*AP_MODULE_DECLARE_DATA*/ search_srv ("search", search_mod);
-static const view view_mod;
-service AP_MODULE_DECLARE_DATA view_srv ("view", view_mod);
+//static const view view_mod;
+//service AP_MODULE_DECLARE_DATA view_srv ("view", view_mod);
diff --git a/web/apache/service b/web/apache/service
index bfa8fa9..a44bdc0 100644
--- a/web/apache/service
+++ b/web/apache/service
@@ -33,7 +33,7 @@ namespace web
handle_impl (request& rq, response& rs, log& l, const module& exemplar)
{
M m (static_cast<const M&> (exemplar));
- m.handle (rq, rs, l);
+ static_cast<module&>(m).handle (rq, rs, l);
}
const module& exemplar_;