chore: added some comments
This commit is contained in:
parent
494946d24a
commit
689a878978
2 changed files with 23 additions and 14 deletions
14
src/main.cpp
14
src/main.cpp
|
|
@ -5,16 +5,16 @@ extern "C" {
|
|||
}
|
||||
|
||||
#define ENV(var, env_var) \
|
||||
const char* _##var = getenv(env_var); \
|
||||
if (_##var == NULL) { \
|
||||
const char *_##var = getenv(env_var); \
|
||||
if (_##var == NULL) { \
|
||||
printf("Missing environment variable %s.\n", env_var); \
|
||||
return 1; \
|
||||
} \
|
||||
} \
|
||||
const std::string var = std::string(_##var);
|
||||
|
||||
#define AUTH() \
|
||||
std::string provided_api_key = req.get_header_value("X-Api-Key"); \
|
||||
if (api_key.compare(provided_api_key) != 0) { \
|
||||
if (api_key.compare(provided_api_key) != 0) { \
|
||||
return crow::response(crow::status::UNAUTHORIZED); \
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +29,8 @@ int main() {
|
|||
|
||||
std::string file_path = "lander.data";
|
||||
|
||||
std::cout << "Populating trie from file '" << file_path << "'..." << std::endl;
|
||||
std::cout << "Populating trie from file '" << file_path << "'..."
|
||||
<< std::endl;
|
||||
|
||||
int count = ternarytrie_populate(trie, file_path.c_str());
|
||||
|
||||
|
|
@ -75,8 +76,7 @@ int main() {
|
|||
});
|
||||
CROW_ROUTE(app, "/<string>")
|
||||
.methods(crow::HTTPMethod::Post)(
|
||||
[api_key, base_url, trie](const crow::request &req,
|
||||
std::string s) {
|
||||
[api_key, base_url, trie](const crow::request &req, std::string s) {
|
||||
AUTH();
|
||||
|
||||
std::string key = req.body;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue