Example #1
0
int
main(int argc, char **argv)
{
    curl_global_init(CURL_GLOBAL_ALL);
    balde_app_t *app = balde_app_init();
    balde_resources_load(app, resources_get_resource());
    balde_app_set_user_data_destroy_func(app, (GDestroyNotify) bluster_gist_ctx_free);
    balde_app_add_before_request(app, bluster_before_request);
    balde_app_add_url_rule(app, "main", "/", BALDE_HTTP_GET, main_view);
    balde_app_add_url_rule(app, "content", "/<slug>/", BALDE_HTTP_GET, main_view);
    balde_app_set_config_from_envvar(app, "oauth_token", "BLUSTER_OAUTH_TOKEN", TRUE);
    balde_app_set_config_from_envvar(app, "gist_id", "BLUSTER_GIST_ID", FALSE);
    balde_app_set_config_from_envvar(app, "gist_ttl", "BLUSTER_GIST_TTL", TRUE);
    balde_app_run(app, argc, argv);
    balde_app_free(app);
    curl_global_cleanup();
    return 0;
}
Example #2
0
void
test_app_set_config_from_envvar(void)
{
    g_setenv("BOLA_CONFIG_ENVVAR", "guda", TRUE);
    balde_app_t *app = balde_app_init();
    balde_app_set_config_from_envvar(app, "foo", "BOLA_CONFIG_ENVVAR", FALSE);
    g_assert(g_hash_table_size(app->priv->config) == 1);
    g_assert_cmpstr(g_hash_table_lookup(app->priv->config, "foo"), ==, "guda");
    balde_app_free(app);
}
Example #3
0
void
test_app_set_config_from_envvar_not_found_silent(void)
{
    balde_app_t *app = balde_app_init();
    balde_app_set_config_from_envvar(app, "foo", "BOLA_CONFIG_ENVVAR3", TRUE);
    g_assert(app->error == NULL);
    g_assert(g_hash_table_size(app->priv->config) == 1);
    g_assert(g_hash_table_lookup(app->priv->config, "foo") == NULL);
    balde_app_free(app);
}
Example #4
0
void
test_app_set_config_from_envvar_not_found(void)
{
    balde_app_t *app = balde_app_init();
    balde_app_set_config_from_envvar(app, "foo", "BOLA_CONFIG_ENVVAR2", FALSE);
    g_assert(app->error != NULL);
    g_assert_cmpstr(app->error->message, ==,
        "The server encountered an internal error and was unable to complete "
        "your request. Either the server is overloaded or there is an error in "
        "the application.\n"
        "\n"
        "BOLA_CONFIG_ENVVAR2 environment variable must be set");
    g_assert(g_hash_table_size(app->priv->config) == 0);
    balde_app_free(app);
}