-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.cpp
More file actions
49 lines (45 loc) · 1.47 KB
/
service.cpp
File metadata and controls
49 lines (45 loc) · 1.47 KB
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
#include "crow.h"
#include "service.h"
#include "controller.h"
#include "database.h"
#include "error_code.h"
#include "cors.h"
#include "error_handler.h"
#include "route.h"
#include "token.h"
#include "response.h"
static void test(const crow::request& req, crow::response& res, const Poco::JSON::Object& token) {
// throw "opp";
// throw CError(5000);
Poco::JSON::Object jres;
jres.set("test", 9);
res.write(responseSuccess(jres));
// res.write(token.get("user_id").toString());
res.end();
}
static void test2(const crow::request& req, crow::response& res, crow::json::rvalue& jval) {
// throw "opp";
// CController con;
auto ret = RunOperation(CController(), &CController::test, 10);
throw CError(5000);
res.write("oop");
// res.write(token.get("user_id").toString());
res.end();
}
static void test3(const crow::request& req, crow::response& res)
{
throw CError(5000);
}
void startService()
{
CDatabase::Connect(POSTGRESQL, "sugar2", "postgres", "postgres", "192.168.100.103", "10202");
crow::App<CorsMiddleware> app;
// auto f = CROW_JSON_PARSE_FUNC(test2);
// CROW_TOEKN_CHECK_FUNC(f);
// CROW_ROUTE(app, "/test").methods(crow::HTTPMethod::GET)
// (CROW_JSON_PARSE_FUNC(test2));
// CROW_ROUTE(app, "/test2").methods(crow::HTTPMethod::GET)
// (CROW_ERROR_HANDLER(test3));
CROW_ROUTE_CUSTOM(app, "/test3", crow::HTTPMethod::GET, CROW_TOEKN_CHECK_HANDLER(test));
app.port(8788).concurrency(3).run();
}