#include #include #include #include #include #include #include #include #include #include #include "db.gen.h" #include "handlers.h" void handle_lb(evapp_ctx *ctx) { struct evbuffer *databuf = evbuffer_new(); struct evhttp_request *request = evapp_request(ctx); assert(databuf != NULL); evbuffer_add_printf(databuf, "OK"); evhttp_send_reply(request, HTTP_OK, "OK", databuf); evbuffer_free(databuf); return; } void handle_quit(evapp_ctx *ctx) { struct timeval tv; struct evhttp_request *request = evapp_request(ctx); if (strcmp(request->remote_host, "127.0.0.1")) { send_forbidden(ctx, "Disallowed for source"); return; } response_cacheable(ctx, CACHE_NONE, 0); send_ok(ctx, "Goodbye!"); /* XXX: End the libevent loop - later roll this into evapp */ tv.tv_sec = 0; tv.tv_usec = 750; event_loopexit(&tv); }