Fixed variable capture problem.
This commit is contained in:
parent
bad43c66d7
commit
ace3bb6caf
@ -47,6 +47,8 @@ std::string dump_request(Context& cxt)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
if (true) {
|
if (true) {
|
||||||
|
const char* s = "abcde";
|
||||||
|
|
||||||
// DSL style
|
// DSL style
|
||||||
HTTP_SERVER("localhost", 1234) {
|
HTTP_SERVER("localhost", 1234) {
|
||||||
|
|
||||||
@ -57,6 +59,10 @@ int main(void)
|
|||||||
GET("/home", {
|
GET("/home", {
|
||||||
res.set_content(dump_request(cxt));
|
res.set_content(dump_request(cxt));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
GET("/abcde", {
|
||||||
|
res.set_content(s);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Regular style
|
// Regular style
|
||||||
|
@ -416,7 +416,7 @@ inline void Server::process_request(FILE* fp_read, FILE* fp_write)
|
|||||||
svr->run(), svr.reset())
|
svr->run(), svr.reset())
|
||||||
|
|
||||||
#define GET(url, body) \
|
#define GET(url, body) \
|
||||||
svr->get(url, [](httpsvrkit::Context& cxt) { \
|
svr->get(url, [&](httpsvrkit::Context& cxt) { \
|
||||||
const auto& req = cxt.request; \
|
const auto& req = cxt.request; \
|
||||||
auto& res = cxt.response; \
|
auto& res = cxt.response; \
|
||||||
body \
|
body \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user