aboutsummaryrefslogtreecommitdiff
path: root/mod/mod-repository-root.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-12 15:28:32 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-12 15:34:00 +0300
commit4b5c7b13f0ebd44c05b50ef8c3e56b0d02bfc4fe (patch)
tree82b8748af9b4b5cb43f062adfd5060e345fef92c /mod/mod-repository-root.cxx
parent30f4cd73410479a95cc7a21958a594d2d7e5993f (diff)
Use 'builds' parameter instead of 'pn' for ?builds handler
Diffstat (limited to 'mod/mod-repository-root.cxx')
-rw-r--r--mod/mod-repository-root.cxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/mod/mod-repository-root.cxx b/mod/mod-repository-root.cxx
index 367b137..27901d7 100644
--- a/mod/mod-repository-root.cxx
+++ b/mod/mod-repository-root.cxx
@@ -28,8 +28,11 @@ using namespace brep::cli;
namespace brep
{
- // Request proxy. Removes the first parameter that is assumed to be a
- // function name.
+ // Request proxy.
+ //
+ // Removes the first parameter, that is assumed to be a function name, if its
+ // value is not present. Otherwise, considers it as the handler's "default"
+ // parameter value and renames the parameter to "_".
//
class request_proxy: public request
{
@@ -45,9 +48,15 @@ namespace brep
if (!parameters_ || url_only < url_only_parameters_)
{
parameters_ = request_.parameters (limit, url_only);
-
assert (!parameters_->empty ()); // Always starts with a function name.
- parameters_->erase (parameters_->begin ());
+
+ auto i (parameters_->begin ());
+ removed_ = !i->value;
+
+ if (removed_)
+ parameters_->erase (i);
+ else
+ i->name = "_";
url_only_parameters_ = url_only;
}
@@ -58,10 +67,9 @@ namespace brep
istream&
open_upload (size_t index)
{
- // The original request object still contains the function name entry,
- // so we shift the index.
+ // Shift the index if the function name parameter was removed.
//
- return request_.open_upload (index + 1);
+ return request_.open_upload (index + (removed_ ? 1 : 0));
}
istream&
@@ -88,6 +96,7 @@ namespace brep
request& request_;
optional<name_values> parameters_;
bool url_only_parameters_; // Meaningless if parameters_ is not present.
+ bool removed_ = false; // If the function name parameter was removed.
};
// repository_root