From 7c8e064216cc672557cbf3892ff090490505e408 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Thu, 18 Apr 2013 15:42:54 +0200 Subject: leveldb: size restricted range query --- datastore-leveldb/src/main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'datastore-leveldb/src/main.cpp') 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; -- cgit v1.2.1