forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
threads.h
Copy pathMore file actions
57 lines (45 loc) · 2.09 KB
/
threads.h
File metadata and controls
57 lines (45 loc) · 2.09 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
50
51
52
53
54
55
56
57
#pragma once
#include <drogon/HttpController.h>
#include <trantor/utils/Logger.h>
#include "services/message_service.h"
#include "services/thread_service.h"
using namespace drogon;
class Threads : public drogon::HttpController<Threads, false> {
public:
METHOD_LIST_BEGIN
ADD_METHOD_TO(Threads::CreateThread, "/v1/threads", Options, Post);
ADD_METHOD_TO(Threads::ListThreads,
"/v1/"
"threads?limit={limit}&order={order}&after={after}&before={"
"before}",
Get);
ADD_METHOD_TO(Threads::RetrieveThread, "/v1/threads/{thread_id}", Get);
ADD_METHOD_TO(Threads::ModifyThread, "/v1/threads/{thread_id}", Options,
Patch);
ADD_METHOD_TO(Threads::DeleteThread, "/v1/threads/{thread_id}", Options,
Delete);
METHOD_LIST_END
explicit Threads(std::shared_ptr<ThreadService> thread_srv,
std::shared_ptr<MessageService> msg_srv)
: thread_service_{thread_srv}, message_service_{msg_srv} {}
void CreateThread(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback);
void ListThreads(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
std::optional<std::string> limit,
std::optional<std::string> order,
std::optional<std::string> after,
std::optional<std::string> before) const;
void RetrieveThread(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id) const;
void ModifyThread(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id);
void DeleteThread(const HttpRequestPtr& req,
std::function<void(const HttpResponsePtr&)>&& callback,
const std::string& thread_id);
private:
std::shared_ptr<ThreadService> thread_service_;
std::shared_ptr<MessageService> message_service_;
};