Skip to content

Commit

Permalink
update errors example with recent change
Browse files Browse the repository at this point in the history
  • Loading branch information
ghedo committed Dec 19, 2011
1 parent 2559637 commit 22f06f0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions eg/example-errors.c
@@ -1,5 +1,17 @@
#include <tofu.h>

tofu_rep_t *handler_root(tofu_req_t *req) {
tofu_rep_t *rep = tofu_rep_init();

tofu_head(rep, "Content-Type", "text/html");

/* some random error occurred here */

tofu_status(rep, 500);

return rep;
}

tofu_rep_t *handler_404(tofu_req_t *req) {
tofu_rep_t *rep = tofu_rep_init();

Expand All @@ -24,6 +36,8 @@ 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);

Expand Down

0 comments on commit 22f06f0

Please sign in to comment.