-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.cc
42 lines (40 loc) · 3.27 KB
/
main.cc
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
#include "msg_controller.h"
#include "user_controller.h"
#include "file_controller.h"
using namespace drogon;
int main()
{
drogon::app().addListener("0.0.0.0", 8081);
//std::cout << "ready" << std::endl;
drogon::app().registerHandler("/api/getKey", [](const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> && callback)
{ getPublicKey(req, std::move(callback)); });
drogon::app().registerHandler("/api/signup", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ Handle(req, std::move(callback), registerUser); });
drogon::app().registerHandler("/api/login", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ Handle(req, std::move(callback), loginUser); });
drogon::app().registerHandler("/api/chat", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ chat(req, std::move(callback)); });
drogon::app().registerHandler("/api/check", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ check(req, std::move(callback)); });
drogon::app().registerHandler("/api/nfmgr", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ request_processing(req, std::move(callback)); });
drogon::app().registerHandler("/api/newfriends", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ friend_operation(req, std::move(callback)); });
drogon::app().registerHandler("/api/info", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ info(req, std::move(callback)); });
drogon::app().registerHandler("/api/file/save", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ saveFile(req, std::move(callback)); });
drogon::app().registerHandler("/api/avatar", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ avatar(req, std::move(callback)); });
drogon::app().registerHandler("/api/upload", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ imageUpload(req, std::move(callback)); });
drogon::app().registerHandler("/api/file/get", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ getPicture(req, std::move(callback)); },
{Get});
drogon::app().registerHandler("/api/file/commands", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ commandsCtrl(req, std::move(callback)); });
drogon::app().registerHandler("/api/file/lock", [](const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
{ add_lock(req, std::move(callback)); });
drogon::app().setUploadPath("./uploads").run();
return 0;
}