summaryrefslogtreecommitdiff
path: root/datastore-leveldb/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'datastore-leveldb/src/main.cpp')
-rw-r--r--datastore-leveldb/src/main.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/datastore-leveldb/src/main.cpp b/datastore-leveldb/src/main.cpp
index 3b0dd98..3000a25 100644
--- a/datastore-leveldb/src/main.cpp
+++ b/datastore-leveldb/src/main.cpp
@@ -19,10 +19,12 @@ struct mg_context *ctx;
int begin_request_handler(struct mg_connection *conn) {
boost::cmatch match;
- const char *url = mg_get_request_info(conn)->uri;
+ const struct mg_request_info *request_info = mg_get_request_info(conn);
for (auto item = web_handler.begin(); item != web_handler.end(); ++item) {
- if (boost::regex_match(url, match, (*item).first)) {
+ if (boost::regex_match(request_info->uri, match, (*item).first)) {
+ std::cout << request_info->request_method << " "
+ << request_info->uri << std::endl;
(*item).second(match, conn);
return 1;
}
@@ -52,12 +54,15 @@ int main(int argc, char **argv) {
// Routing
web_handler.push_front(std::make_pair(
- boost::regex("/api/value/([a-zA-Z0-9]+)/([0-9]+)"),
+ web_handle_api_value_R,
web_handle_api_value));
web_handler.push_front(std::make_pair(
- boost::regex("/api/range/([a-zA-Z0-9]+)/([0-9]+)/([0-9]+)"),
+ web_handle_api_range_R,
web_handle_api_range));
-
+ web_handler.push_front(std::make_pair(
+ web_handle_api_range_size_R,
+ web_handle_api_range_size));
+
// Signals: handle C-c
struct sigaction action;