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

Function main

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

Source from the content-addressed store, hash-verified

88}
89
90int main(int argc, char *argv[])
91{
92 acl::acl_cpp_init();
93
94 master_service ms;
95 http_service& service = ms.get_service();
96
97 // setup the configure
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 if (argc == 1 || (argc >= 2 && strcasecmp(argv[1], "alone") == 0)) {
133 // ��־�������׼���
134 acl::log::stdout_open(true);
135 // ��ֹ���� acl_master.log ��־
136 acl::master_log_enable(false);
137
138 const char* addr = "|8888";
139
140 if (argc >= 4) {
141 addr = argv[3];
142 }
143 printf("listen: %s\r\n", addr);
144
145 ms.run_alone(addr, argc >= 3 ? argv[2] : NULL);
146 } else {
147#if defined(_WIN32) || defined(_WIN64)

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…