예제 #1
0
int main() {
	char *opts[] = { "0.0.0.0", "2000" };
	tofu_ctx_t *ctx = tofu_ctx_init(TOFU_EVHTTP, opts);

	tofu_handle_with(ctx, POST, "/post/:data", eg_handler);

	tofu_loop(ctx);
	tofu_ctx_free(ctx);

	return 0;
}
예제 #2
0
int main() {
	char *opts[] = { "0.0.0.0", "2000" };
	tofu_ctx_t *ctx = tofu_ctx_init(TOFU_EVHTTP, opts);

	tofu_handle_with(ctx, GET, "/coffee", handler, NULL);

	tofu_rescue_with(ctx, 418, error_418);

	tofu_loop(ctx);
	tofu_ctx_free(ctx);

	return 0;
}
예제 #3
0
int main() {
	char *opts[] = { "0.0.0.0", "2000" };
	tofu_ctx_t *ctx = tofu_ctx_init(TOFU_EVHTTP, opts);

	tofu_handle_with(ctx, GET, "/", handler_root);

	tofu_rescue_with(ctx, 404, handler_404);
	tofu_rescue_with(ctx, 500, handler_500);

	tofu_loop(ctx);
	tofu_ctx_free(ctx);

	return 0;
}