Skip to content

Commit

Permalink
also update the status example
Browse files Browse the repository at this point in the history
  • Loading branch information
ghedo committed Dec 19, 2011
1 parent 22f06f0 commit 91a2cae
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eg/example-status.c
Expand Up @@ -3,6 +3,14 @@
tofu_rep_t *handler(tofu_req_t *req) {
tofu_rep_t *rep = tofu_rep_init();

tofu_status(rep, 418);

return rep;
}

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

tofu_status(rep, 418);
tofu_head(rep, "Content-Type", "text/html");
tofu_write(rep, "<!DOCTYPE html>\n<head><title>I'm a teapot</title></head><body><h1>418 - Sorry, I'm just a teapot!</h1></body>\n");
Expand All @@ -16,6 +24,8 @@ int main() {

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

tofu_rescue_with(ctx, 418, error_418);

tofu_loop(ctx);
tofu_ctx_free(ctx);

Expand Down

0 comments on commit 91a2cae

Please sign in to comment.