-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "librender_cdk/extern/cpp-httplib"] | ||
path = librender_cdk/extern/cpp-httplib | ||
url = https://github.com/lexara-prime-ai/cpp-httplib | ||
[submodule "librender_cdk/extern/dotenv-cpp"] | ||
path = librender_cdk/extern/dotenv-cpp | ||
url = https://github.com/lexara-prime-ai/dotenv-cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule dotenv-cpp
added at
432def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "../../librender_cdk/extern/dotenv-cpp/include/laserpants/dotenv/dotenv.h" | ||
#include <cstdlib> | ||
#include <iostream> | ||
#include <string> | ||
|
||
struct Config { | ||
std::string api_key; | ||
std::string owner_credentials; | ||
}; | ||
|
||
Config load_config() { | ||
dotenv::init(".env"); | ||
|
||
const char *api_key = std::getenv("API_KEY"); | ||
const char *owner_credentials = std::getenv("OWNER_CREDENTIALS"); | ||
|
||
Config config; | ||
if (api_key) | ||
config.api_key = api_key; | ||
if (owner_credentials) | ||
config.owner_credentials = owner_credentials; | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef ENVIRONMENT_MANAGER_H | ||
#define ENVIRONMENT_MANAGER_H | ||
|
||
#include <string> | ||
|
||
struct Config { | ||
std::string api_key; | ||
std::string owner_credentials; | ||
}; | ||
|
||
Config load_config(); | ||
|
||
#endif // ENVIRONMENT_MANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
#include "../cpp-httplib/httplib.h" | ||
#include "environment_manager.h" | ||
#include <iostream> | ||
|
||
int main() { | ||
httplib::Client cli("http://example.com"); | ||
auto res = cli.Get("/api/v1/resource"); | ||
// Call the load_config function to load environment variables | ||
Config config = load_config(); | ||
|
||
if (res) { | ||
std::cout << "Status: " << res->status << std::endl; | ||
std::cout << "Response Body: " << res->body << std::endl; | ||
} | ||
// Print the loaded configuration values | ||
std::cout << "API_KEY: " << config.api_key << std::endl; | ||
std::cout << "OWNER_CREDENTIALS: " << config.owner_credentials << std::endl; | ||
|
||
return 0; | ||
} | ||
|
||
// #include "../cpp-httplib/httplib.h" | ||
// #include <iostream> | ||
|
||
// int main() { | ||
// httplib::Client cli("http://example.com"); | ||
// auto res = cli.Get("/api/v1/resource"); | ||
|
||
// if (res) { | ||
// std::cout << "Status: " << res->status << std::endl; | ||
// std::cout << "Response Body: " << res->body << std::endl; | ||
// } | ||
// } |