32 |
mg_printf(conn, "%s", "HTTP/1.1 200 OK\r\n"); |
mg_printf(conn, "%s", "HTTP/1.1 200 OK\r\n"); |
33 |
mg_printf(conn, "%s", "Content-Type: text/plain\r\n\r\n"); |
mg_printf(conn, "%s", "Content-Type: text/plain\r\n\r\n"); |
34 |
|
|
35 |
mg_printf(conn, "%s", os.str().c_str() ); |
mg_printf(conn, "%s", os.str().c_str() ); |
36 |
|
} |
37 |
|
|
38 |
|
void show_index(struct mg_connection *conn, const struct mg_request_info *request_info, void *user_data) { |
39 |
|
mg_printf(conn, "%s", "HTTP/1.1 200 OK\r\n"); |
40 |
|
mg_printf(conn, "%s", "Content-Type: text/plain\r\n\r\n"); |
41 |
|
|
42 |
|
mg_printf(conn, "%s", "<html><body><h2>smsdaemon</h2>\n"); |
43 |
|
mg_printf(conn, "%s", "<a href='/status'>smsdaemon status</a>\n"); |
44 |
|
mg_printf(conn, "%s", "</body></html>"); |
45 |
} |
} |
46 |
|
|
47 |
void EmbeddedHttp::startServer() { |
void EmbeddedHttp::startServer() { |
49 |
|
|
50 |
m_context = mg_start(); |
m_context = mg_start(); |
51 |
mg_set_option(m_context, "ports", "8080"); |
mg_set_option(m_context, "ports", "8080"); |
52 |
|
mg_set_uri_callback(m_context, "/", &show_index, 0); |
53 |
mg_set_uri_callback(m_context, "/status", &show_secret, 0); |
mg_set_uri_callback(m_context, "/status", &show_secret, 0); |
54 |
|
|
55 |
} |
} |