-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
66 lines (49 loc) · 2.17 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <lwan/lwan.h>
#include <lwan/lwan-mod-serve-files.h>
#include "controller/index.h"
#include "controller/passage.h"
#include "controller/sendpsg.h"
#include "controller/login.h"
#include "controller/newuser.h"
#include "controller/userstatus.h"
SEND_FILE_HANDLER_CREATE(favicon,"./view/favicon.ico","image/x-icon");
SEND_FILE_HANDLER_CREATE(robots_txt,"./view/robots.txt","text/txt");
int
main(void)
{
const struct lwan_url_map default_map[] = {
{ .prefix = "/", .handler = LWAN_HANDLER_REF(index) },
{ .prefix = "/psg/", .handler = LWAN_HANDLER_REF(passage) },
{ .prefix = "/api/sendpsg", .handler = LWAN_HANDLER_REF(sendpsg) },
{ .prefix = "/api/getpsg", .handler = LWAN_HANDLER_REF(getpsg) },
{ .prefix = "/api/delpsg", .handler = LWAN_HANDLER_REF(delpsg) },
{ .prefix = "/api/editpsg", .handler = LWAN_HANDLER_REF(editpsg) },
{ .prefix = "/api/preview", .handler = LWAN_HANDLER_REF(preview) },
{ .prefix = "/api/getClass", .handler = LWAN_HANDLER_REF(getClass) },
{ .prefix = "/api/getClasses", .handler = LWAN_HANDLER_REF(getClasses) },
{ .prefix = "/api/login", .handler = LWAN_HANDLER_REF(login) },
{ .prefix = "/api/newuser", .handler = LWAN_HANDLER_REF(newuser) },
{ .prefix = "/api/isloged", .handler = LWAN_HANDLER_REF(isloged) },
{ .prefix = "/api/changepwd", .handler = LWAN_HANDLER_REF(changepwd) },
{ .prefix = "/favicon.ico", .handler = SEND_FILE_HANDLER(favicon) },
{ .prefix = "/robots.txt", .handler = SEND_FILE_HANDLER(robots_txt) },
{ .prefix = "/static", SERVE_FILES("./static") },
{ .prefix = NULL }
};
struct lwan l;
lwan_init(&l);
model_init();
SEND_FILE_HANDLER_INIT(favicon);
SEND_FILE_HANDLER_INIT(robots_txt);
controller_passage_init();
controller_index_init();
lwan_set_url_map(&l, default_map);
lwan_main_loop(&l);
lwan_shutdown(&l);
controller_passage_destroy();
controller_index_destroy();
SEND_FILE_HANDLER_CLOSE(favicon);
SEND_FILE_HANDLER_CLOSE(robots_txt);
model_close();
return 0;
}