From cae62ce7d28c7619dacdc0c5d26d9cf07bd09ecc Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Tue, 15 Nov 2022 17:25:04 +0100 Subject: [PATCH] Proof-of-concept --- src/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 72ccf56..e7ab79e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,8 @@ #include "crow.h" + +extern "C" { #include "ternarytrie.h" +} int main() { @@ -7,8 +10,19 @@ int main() crow::SimpleApp app; - CROW_ROUTE(app, "/").methods(crow::HTTPMethod::Get, crow::HTTPMethod::Post)([](){ - return "Hello world"; + CROW_ROUTE(app, "/").methods(crow::HTTPMethod::Post) + ([trie](std::string s){ + ternarytrie_add(trie, s.c_str()); + + return "added"; + }); + CROW_ROUTE(app, "/").methods(crow::HTTPMethod::Get) + ([trie](std::string s){ + if (ternarytrie_search(trie, s.c_str())) { + return "it's here"; + } + + return "nope"; }); app.port(18080).multithreaded().run();