@ -1,3 +1,4 @@
|
||||
#include <ctorm/app.h>
|
||||
#include <ctorm/ctorm.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -19,25 +20,28 @@ int main() {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// initialize the app config
|
||||
ctorm_config_new(&app_config);
|
||||
app_config.disable_logging = true;
|
||||
app = ctorm_app_new(&app_config);
|
||||
|
||||
// create a new app
|
||||
app = ctorm_app_new(&app_config);
|
||||
|
||||
// middlewares
|
||||
MIDDLEWARE_ALL(app, "/*", route_cors);
|
||||
MIDDLEWARE_ALL(app, "/*/*", route_cors);
|
||||
ALL(app, "/*", route_cors);
|
||||
ALL(app, "/*/*", route_cors);
|
||||
|
||||
// routes
|
||||
GET(app, "/list", route_list);
|
||||
GET(app, "/get/:name", route_get);
|
||||
|
||||
ctorm_app_all(app, route_notfound);
|
||||
ctorm_app_default(app, route_notfound);
|
||||
ctorm_app_local(app, "config", &conf);
|
||||
|
||||
ctorm_info("starting the web server on %s", host);
|
||||
|
||||
if (!ctorm_app_run(app, host))
|
||||
ctorm_fail("failed to start the app: %s", ctorm_geterror());
|
||||
ctorm_fail("failed to start the app: %s", ctorm_error());
|
||||
|
||||
ctorm_app_free(app);
|
||||
return EXIT_SUCCESS;
|
||||
|
Reference in New Issue
Block a user