MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

app/wizard/tmpl/http/main_proc.cpp:90–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90int 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;

Callers

nothing calls this directly

Calls 13

acl_cpp_initFunction · 0.85
master_log_enableFunction · 0.85
set_cfg_boolMethod · 0.80
set_cfg_strMethod · 0.80
set_cfg_int64Method · 0.80
set_cfg_intMethod · 0.80
websocket_runFunction · 0.70
GetMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
formatMethod · 0.45
run_aloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…