| 88 | } |
| 89 | |
| 90 | int main(int argc, char* argv[]) |
| 91 | { |
| 92 | // ��ʼ�� acl �� |
| 93 | acl::acl_cpp_init(); |
| 94 | |
| 95 | master_service ms; |
| 96 | http_service& service = ms.get_service(); |
| 97 | |
| 98 | // ���������� |
| 99 | ms.set_cfg_int(var_conf_int_tab) |
| 100 | .set_cfg_int64(var_conf_int64_tab) |
| 101 | .set_cfg_str(var_conf_str_tab) |
| 102 | .set_cfg_bool(var_conf_bool_tab); |
| 103 | |
| 104 | // Register http handlers according different url path |
| 105 | service.Get("/", http_get_root) |
| 106 | .Get("/ok", http_get_ok) |
| 107 | .Post("/ok", http_post_ok) |
| 108 | .Get("/json", http_get_json) |
| 109 | .Get("/xml", http_get_xml) |
| 110 | #ifdef USE_LAMBDA |
| 111 | .Get("/test1", [](HttpRequest&, HttpResponse& res) { |
| 112 | acl::string buf("test1: hello world!\r\n"); |
| 113 | res.setContentLength(buf.size()); |
| 114 | return res.write(buf); |
| 115 | }).Get("/test2", [&](HttpRequest&, HttpResponse& res) { |
| 116 | acl::string buf("test2: hello world!\r\n"); |
| 117 | res.setContentLength(buf.size()); |
| 118 | return res.write(buf); |
| 119 | }).Default([](const char* path, HttpRequest&, HttpResponse& res) { |
| 120 | acl::string buf; |
| 121 | buf.format("Default(%s): hello world!\r\n", path); |
| 122 | res.setContentLength(buf.size()); |
| 123 | return res.write(buf); |
| 124 | }).Websocket("/", [](HttpRequest& req, HttpResponse& res) { |
| 125 | return websocket_run(req, res); |
| 126 | }); |
| 127 | #else |
| 128 | .Websocket("/", websocket_run) |
| 129 | .Default(http_get_default); |
| 130 | #endif |
| 131 | |
| 132 | // ��ʼ���� |
| 133 | if (argc == 1 || (argc >= 2 && strcmp(argv[1], "alone") == 0)) { |
| 134 | // ��־���������� |
| 135 | acl::log::stdout_open(true); |
| 136 | // ��ֹ���� acl_master.log ��־ |
| 137 | acl::master_log_enable(false); |
| 138 | |
| 139 | // �����ĵ�ַ�б�����ʽ��ip|port1,ip|port2,... |
| 140 | const char* addrs = "|8888"; |
| 141 | printf("listen on: %s\r\n", addrs); |
| 142 | |
| 143 | // ����ʱ���ø�ֵ > 0 ��ָ�������������ͻ������ӹ��̵� |
| 144 | // �Ự������һ�����Ӵӽ��յ��رճ�֮Ϊһ���Ự������ |
| 145 | // ���������ӻỰ��������ֵ�����Թ��̽����������ֵ�� |
| 146 | // Ϊ 0������Թ�����Զ������ |
| 147 | int count = 0; |
nothing calls this directly
no test coverage detected
searching dependent graphs…