FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
expresscpp/include/expresscpp/expresscpp.hpp at master · kassane/expresscpp · GitHub
kassane
/
expresscpp
Public
forked from
expresscpp/expresscpp
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
expresscpp
/
include
/
expresscpp
/
expresscpp.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
135 lines (114 loc) · 3.46 KB
Breadcrumbs
expresscpp
/
include
/
expresscpp
/
expresscpp.hpp
Copy path
File metadata and controls
135 lines (114 loc) · 3.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
if
defined(__cpp_modules)
export
module
expresscpp;
export
import
std;
#
else
#
pragma
once
#
endif
#
include
<
filesystem
>
#
include
<
functional
>
#
include
<
iostream
>
#
include
<
memory
>
#
include
<
vector
>
#
include
"
expresscpp/impl/listener.hpp
"
#
include
"
expresscpp/impl/routing_stack.hpp
"
#
include
"
expresscpp/nextrouter.hpp
"
#
include
"
expresscpp/request.hpp
"
#
include
"
expresscpp/response.hpp
"
#
include
"
expresscpp/route.hpp
"
#
include
"
expresscpp/router.hpp
"
#
include
"
expresscpp/types.hpp
"
#
include
"
expresscpp/exports.hpp
"
#
if
defined(__cpp_modules)
export
namespace
expresscpp
{
#
else
namespace
expresscpp
{
#endif
class
EXPRESSCPP_API
ExpressCpp {
friend
class
Session
;
public:
ExpressCpp
();
~ExpressCpp
();
template
<
typename
T>
void
Get
(std::string_view registered_path, T handler) {
router_->
Get
(registered_path, handler);
}
template
<
typename
T,
typename
... Args>
void
Get
(std::string_view path, T handler, Args... args) {
Get
(path, handler);
Get
(path, args...);
}
template
<
typename
T>
void
Put
(std::string_view registered_path, T handler) {
router_->
Put
(registered_path, handler);
}
template
<
typename
T,
typename
... Args>
void
Put
(std::string_view path, T handler, Args... args) {
Put
(path, handler);
Put
(path, args...);
}
template
<
typename
T>
void
Post
(std::string_view registered_path, T handler) {
router_->
Post
(registered_path, handler);
}
template
<
typename
T,
typename
... Args>
void
Post
(std::string_view path, T handler, Args... args) {
Post
(path, handler);
Post
(path, args...);
}
template
<
typename
T>
void
Delete
(std::string_view registered_path, T handler) {
router_->
Delete
(registered_path, handler);
}
template
<
typename
T,
typename
... Args>
void
Delete
(std::string_view path, T handler, Args... args) {
Delete
(path, handler);
Delete
(path, args...);
}
template
<
typename
T>
void
Patch
(std::string_view registered_path, T handler) {
router_->
Patch
(registered_path, handler);
}
template
<
typename
T,
typename
... Args>
void
Patch
(std::string_view path, T handler, Args... args) {
Patch
(path, handler);
Patch
(path, args...);
}
void
Error
(
handler_wecn_t
handler);
/*
!
* Proxy `Router#Use()` to add middleware to the app router.
* See Router#use() documentation for details.
*
* If the _fn_ parameter is an express app, then it will be
* mounted at the _route_ specified.
*/
void
Use
(
handler_wn_t
handler);
void
Use
(std::string_view path,
handler_t
handler);
void
Use
(std::string_view path,
handler_wn_t
handler);
void
Use
(std::string_view path, RouterPtr router);
Router&
Use
(std::string_view path);
auto
GetBaseRouter
();
//
! called to start listening on port
ExpressCpp&
Listen
(
const
uint16_t
port,
ready_fn_cb_error_code_t
callback);
void
Run
();
void
Stop
();
RouterPtr
GetRouter
()
const
;
RouterPtr
GetRouter
(std::string_view name)
const
;
std::vector<RoutingStack>
Stack
()
const
;
/*
*
* Dispatch a req, res pair into the application. Starts pipeline processing.
*/
void
HandleRequest
(
request_t
req,
response_t
res, std::function<
void
()> callback);
private:
void
Init
();
std::mutex running_mtx;
std::condition_variable running_cv;
bool
finished_{
false
};
std::unique_ptr<Router> router_;
std::shared_ptr<Listener> listener_;
std::vector<Route> routes_;
std::
size_t
threads_{
4u
};
bool
error_handler_registered_{
false
};
handler_wecn_t
error_handler_;
bool
listening_{
false
};
};
}
//
namespace expresscpp
Back
|
FazBrowse Home
|
New Git URL