38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
#include <stdio.h>
|
|
|
|
#include "lander.h"
|
|
#include "log.h"
|
|
|
|
#define ENV(var, env_var) \
|
|
const char *var = getenv(env_var); \
|
|
if (var == NULL) { \
|
|
critical(1, "Missing environment variable %s", env_var); \
|
|
} \
|
|
var = strdup(var);
|
|
|
|
int main() {
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
|
|
|
ENV(api_key, "LANDER_API_KEY");
|
|
|
|
info("Initializing trie");
|
|
|
|
Trie *trie;
|
|
TrieExitCode res = trie_init(&trie, "lander.data");
|
|
|
|
if (res != Ok) {
|
|
critical(1, "An error occured while populating the trie.");
|
|
}
|
|
|
|
info("Trie initialized and populated with %i entries", trie_size(trie));
|
|
|
|
http_loop_gctx *gctx = http_loop_gctx_init();
|
|
gctx->trie = trie;
|
|
gctx->routes = lander_routes;
|
|
gctx->route_count = sizeof(lander_routes) / sizeof(lander_routes[0]);
|
|
gctx->api_key = api_key;
|
|
event_loop *el = http_loop_init(gctx);
|
|
|
|
http_loop_run(el, 18080);
|
|
}
|