| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <stdint.h> |
| #include <errno.h> |
| #include <evhtp.h> |
| |
| void |
| testcb(evhtp_request_t * req, void * a) { |
| evbuffer_add_reference(req->buffer_out, "foobar", 6, NULL, NULL); |
| evhtp_send_reply(req, EVHTP_RES_OK); |
| } |
| |
| int |
| main(int argc, char ** argv) { |
| evbase_t * evbase = event_base_new(); |
| evhtp_t * htp = evhtp_new(evbase, NULL); |
| |
| evhtp_set_cb(htp, "/test", testcb, NULL); |
| #ifndef EVHTP_DISABLE_EVTHR |
| evhtp_use_threads(htp, NULL, 4, NULL); |
| #endif |
| evhtp_bind_socket(htp, "0.0.0.0", 8081, 1024); |
| event_base_loop(evbase, 0); |
| return 0; |
| } |
| |