Closed CraigglesO closed 6 years ago
I couldn't find an answer in your other issues so here it goes:
#include "crow_all.h" #include "server.h" class Server { public: Server(std::string input_folder) { // acquire the protobuf file rtree = getRtree(input_folder); // reverseGeocode CROW_ROUTE(app, "/reverse") .methods("POST"_method) ([this](const crow::request& req) { auto coord = crow::json::load(req.body); if (!coord) return crow::response(400); double lon = coord["lon"].d(); double lat = coord["lat"].d(); std::string res = rtree->nearestSingle(lon, lat, 180); std::ostringstream os; os << res; return crow::response{os.str()}; }); } // create server & rtree crow::SimpleApp app; Rtree<std::string>* rtree; }; int main(int argc, char* argv[]) { std::string input_folder; if (argc != 2) { input_folder = "./"; } Server server(input_folder); server.app.port(18080).multithreaded().run(); }
gives me the proper response the first time, but the this pointer does after one use!
this
Sorry for my ignorance, can you explain a work around?
Thanks, Craig.
I couldn't find an answer in your other issues so here it goes:
gives me the proper response the first time, but the
this
pointer does after one use!Sorry for my ignorance, can you explain a work around?
Thanks, Craig.