Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Forward patch request to leader
Jason Boscod2206168ec8e
diff --git a/include/http_client.h b/include/http_client.hindex cc8d2af4..2611decf 100644--- a/include/http_client.h+++ b/include/http_client.h@@ -58,5 +58,8 @@ public:static long put_response(const std::string & url, const std::string & body, std::string & response,std::map<std::string, std::string>& res_headers, long timeout_ms=4000);+ static long patch_response(const std::string & url, const std::string & body, std::string & response,+ std::map<std::string, std::string>& res_headers, long timeout_ms=4000);+static void extract_response_headers(CURL* curl, std::map<std::string, std::string> &res_headers);};diff --git a/src/http_client.cpp b/src/http_client.cppindex c4b5a53f..b6579c81 100644--- a/src/http_client.cpp+++ b/src/http_client.cpp@@ -46,6 +46,18 @@ long HttpClient::put_response(const std::string &url, const std::string &body, sreturn perform_curl(curl, res_headers);}+long HttpClient::patch_response(const std::string &url, const std::string &body, std::string &response,+ std::map<std::string, std::string>& res_headers, long timeout_ms) {+ CURL *curl = init_curl(url, response);+ if(curl == nullptr) {+ return 500;+ }++ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PATCH");+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());+ return perform_curl(curl, res_headers);+}+long HttpClient::delete_response(const std::string &url, std::string &response,std::map<std::string, std::string>& res_headers, long timeout_ms) {CURL *curl = init_curl(url, response);diff --git a/src/raft_server.cpp b/src/raft_server.cppindex 3dfd92fa..cf43c49f 100644--- a/src/raft_server.cpp+++ b/src/raft_server.cpp@@ -223,6 +223,11 @@ void ReplicationState::write_to_leader(http_req *request, http_res *response) colong status = HttpClient::delete_response(url, api_res, res_headers);response->content_type_header = res_headers["content-type"];response->set_body(status, api_res);+ } else if(request->http_method == "PATCH") {+ std::string api_res;+ long status = HttpClient::patch_response(url, request->body, api_res, res_headers);+ response->content_type_header = res_headers["content-type"];+ response->set_body(status, api_res);} else {const std::string& err = "Forwarding for http method not implemented: " + request->http_method;LOG(ERROR) << err;