]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/prometheus-cpp/3rdparty/civetweb/conan/test_package/test_package.cpp
2 * Copyright (c) 2018-2020 the CivetWeb developers
6 /* Simple demo of a REST callback. */
20 #define HOST_INFO "http://localhost:8080"
21 #define EXAMPLE_URI "/example"
23 static int exitNow
= 0;
26 ExampleGET(struct mg_connection
* conn
)
28 mg_send_http_ok(conn
, "text/plain", 10);
34 ExampleHandler(struct mg_connection
*conn
, void *cbdata
)
36 const struct mg_request_info
*ri
= mg_get_request_info(conn
);
37 (void)cbdata
; /* currently unused */
39 if (0 == strcmp(ri
->request_method
, "GET")) {
40 return ExampleGET(conn
);
46 log_message(const struct mg_connection
*conn
, const char *message
)
53 main(int argc
, char *argv
[])
55 struct mg_callbacks callbacks
;
56 struct mg_context
*ctx
;
64 /* Callback will print error messages to console */
65 memset(&callbacks
, 0, sizeof(callbacks
));
66 callbacks
.log_message
= log_message
;
68 /* Start CivetWeb web server */
69 ctx
= mg_start(&callbacks
, 0, NULL
);
71 /* Check return value: */
73 fprintf(stderr
, "Cannot start CivetWeb - mg_start failed.\n");
77 /* Add handler EXAMPLE_URI, to explain the example */
78 mg_set_request_handler(ctx
, EXAMPLE_URI
, ExampleHandler
, 0);
81 printf("Start example: %s%s\n", HOST_INFO
, EXAMPLE_URI
);
84 /* Wait until the server should be closed */
93 diff_t
= difftime(end_t
, start_t
);