Skip to content

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

Handle changes in req routes.

Kishore Nallanc074ef1300e6
diff --git a/include/http_data.h b/include/http_data.h
index c060adc7..c435e8d7 100644
--- a/include/http_data.h
+++ b/include/http_data.h
@@ -404,7 +404,7 @@ struct http_req {
struct route_path {
std::string http_method;
std::vector<std::string> path_parts;
- bool (*handler)(const std::shared_ptr<http_req>&, const std::shared_ptr<http_res>&);
+ bool (*handler)(const std::shared_ptr<http_req>&, const std::shared_ptr<http_res>&) = nullptr;
bool async_req;
bool async_res;
std::string action;
diff --git a/src/batched_indexer.cpp b/src/batched_indexer.cpp
index ea23388a..93a19382 100644
--- a/src/batched_indexer.cpp
+++ b/src/batched_indexer.cpp
@@ -103,11 +103,11 @@ std::string BatchedIndexer::get_collection_name(const std::shared_ptr<http_req>&
std::string& coll_name = req->params["collection"];
if(coll_name.empty()) {
- route_path* rpath;
- server->get_route(req->route_hash, &rpath);
+ route_path* rpath = nullptr;
+ bool route_found = server->get_route(req->route_hash, &rpath);
// ensure that collection creation is sent to the same queue as writes to that collection
- if(rpath->handler == post_create_collection) {
+ if(route_found && rpath->handler == post_create_collection) {
nlohmann::json obj = nlohmann::json::parse(req->body, nullptr, false);
if(!obj.is_discarded() && obj.is_object() &&