void test_app_add_before_request(void) { balde_app_t *app = balde_app_init(); balde_app_add_before_request(app, arcoiro_hook); g_assert(app->priv->before_requests != NULL); g_assert(app->priv->before_requests->next == NULL); i = 0; balde_before_request_t *hook = app->priv->before_requests->data; g_assert(hook != NULL); g_assert(hook->before_request_func == arcoiro_hook); hook->before_request_func(app, NULL); g_assert(i == 1); balde_app_free(app); }
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; }