aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-15 09:36:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-15 09:36:24 +0200
commit370e361db628f60bca5509dcc354014569d56752 (patch)
tree7aac3a1e5673ea7da104f615f6c79a0af1be85ba
parenta96a346e4ab58729b1f257268f2d2af1ebdca890 (diff)
Some more cleanups
-rw-r--r--brep/module41
-rw-r--r--brep/module.cxx5
-rw-r--r--web/apache/service2
3 files changed, 24 insertions, 24 deletions
diff --git a/brep/module b/brep/module
index f6144f2..3f7b409 100644
--- a/brep/module
+++ b/brep/module
@@ -5,11 +5,27 @@
#ifndef BREP_MODULE
#define BREP_MODULE
-#include <brep/diagnostics>
+#include <utility> // move()
+
#include <web/module>
+#include <brep/diagnostics>
+
namespace brep
{
+ // Bring in commonly used names from the web namespace.
+ //
+ // @@ Maybe doing using namespace is the right way to handle this.
+ // There will, however, most likely be a conflict between
+ // web::module and our module. Or maybe not, need to try.
+ //
+ using web::status_code;
+ 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
@@ -17,13 +33,13 @@ namespace brep
//
struct invalid_request
{
- web::status_code status {422};
+ status_code status {422};
std::string description;
//@@ Maybe optional "try again" link?
//
- invalid_request (const char* d, web::status_code s = 422)
- : status (s), description (d) {}
+ 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,
@@ -35,7 +51,7 @@ namespace brep
{
diag_data data;
- server_error (diag_data&& d) : data (std::move (d)) {}
+ server_error (diag_data&& d): data (std::move (d)) {}
};
// Every module member function that needs to produce any diagnostics
@@ -63,21 +79,6 @@ namespace brep
// Adaptation of the web::module to our needs.
//
-
- // Bring in commonly used names from the web namespace.
- //
- // @@ Maybe doing using namespace is the right way to handle this.
- // There will, however, most likely be a conflict between
- // web::module and our module. Or maybe not, need to try.
- //
-
- 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
{
public:
diff --git a/brep/module.cxx b/brep/module.cxx
index 8a9d71a..15e996f 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -7,11 +7,10 @@
#include <functional> // bind()
using namespace std;
-using namespace placeholders;
+using namespace placeholders; // For std::bind's _1, etc.
namespace brep
{
-
void module::
handle (request& rq, response& rs, log& l)
{
@@ -27,7 +26,7 @@ namespace brep
//
rs.content (e.status, "text/html;charset=utf-8") << e.description;
}
- catch (server_error& e)
+ catch (server_error& e) // Non-const because of move() below.
{
// @@ Both log and return as 505.
//
diff --git a/web/apache/service b/web/apache/service
index a44bdc0..8dd21d8 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));
- static_cast<module&>(m).handle (rq, rs, l);
+ static_cast<module&> (m).handle (rq, rs, l);
}
const module& exemplar_;