Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding 404 handler and airbrake handler skeleton

  • Loading branch information...
commit 8eb8b77f6196838a0f1dd18dd3978a9c10a10f6c 1 parent 3e542ef
@abedra authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 bungleoServer.c
View
24 bungleoServer.c
@@ -25,6 +25,28 @@ tofu_rep_t *post(tofu_req_t *req, void *socket) {
return rep;
}
+tofu_rep_t *airbrake(tofu_req_t *req, void *socket) {
+ tofu_rep_t *rep = tofu_rep_init();
+ int body_len;
+ char *body = tofu_body(req, &body_len);
+ printf("%s\n", body);
+
+ /* Airbrake sends things in via xml. Need to pull in libxml to handle this request. */
+
+ tofu_status(rep, 200);
+ return rep;
+}
+
+tofu_rep_t *fourOhFour(tofu_req_t *req) {
+ tofu_rep_t *rep = tofu_rep_init();
+ tofu_head(rep, "Content-Type", "text/html");
+ tofu_write(rep, "<!DOCTYPE html>\n<head><title>404</title></head>\n");
+ tofu_write(rep, "<body>Not found</body>\n");
+ printf("Unable to route %s\n", req->uri);
+
+ return rep;
+}
+
int startBungleoServer() {
char *opts[] = { "0.0.0.0", "5000" };
tofu_ctx_t *ctx = tofu_ctx_init(TOFU_EVHTTP, opts);
@@ -33,6 +55,8 @@ int startBungleoServer() {
zmq_bind(sender, "tcp://*:5555");
tofu_handle_with(ctx, POST, "/", post, sender);
+ tofu_handle_with(ctx, POST, "/notifier_api/v2/notices/", airbrake, sender);
+ tofu_rescue_with(ctx, 404, fourOhFour);
tofu_loop(ctx);
zmq_close(sender);
Please sign in to comment.
Something went wrong with that request. Please try again.