You've already forked cpp-httplib
Renamed Context to Connection. Removed DSL macro.
This commit is contained in:
@ -6,14 +6,17 @@
|
||||
//
|
||||
|
||||
#include <httplib.h>
|
||||
using namespace httplib;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
HTTP_SERVER("localhost", 1234) /* svr_ */ {
|
||||
GET("/hi", /* req_, res_ */ {
|
||||
res_.set_content("Hello World!");
|
||||
});
|
||||
}
|
||||
Server svr("localhost", 1234);
|
||||
|
||||
svr.get("/hi", [](Connection& c) {
|
||||
c.response.set_content("Hello World!");
|
||||
});
|
||||
|
||||
svr.run();
|
||||
}
|
||||
|
||||
// vim: et ts=4 sw=4 cin cino={1s ff=unix
|
||||
|
@ -21,26 +21,27 @@ template<typename Fn> void signal(int sig, Fn fn)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
using namespace httplib;
|
||||
|
||||
const char* hi = "/hi";
|
||||
|
||||
HTTP_SERVER("localhost", 1234) /* svr_ */ {
|
||||
Server svr("localhost", 1234);
|
||||
|
||||
GET("/", {
|
||||
res_.set_redirect(hi);
|
||||
});
|
||||
svr.get("/", [=](Connection& c) {
|
||||
c.response.set_redirect(hi);
|
||||
});
|
||||
|
||||
GET("/hi", {
|
||||
res_.set_content("Hello World!");
|
||||
});
|
||||
svr.get("/hi", [](Connection& c) {
|
||||
c.response.set_content("Hello World!");
|
||||
});
|
||||
|
||||
GET("/dump", {
|
||||
res_.set_content(dump_request(cxt));
|
||||
});
|
||||
svr.get("/dump", [](Connection& c) {
|
||||
c.response.set_content(dump_request(c));
|
||||
});
|
||||
|
||||
signal(SIGINT, [&](){
|
||||
svr_->stop();
|
||||
});
|
||||
}
|
||||
signal(SIGINT, [&]() { svr.stop(); });
|
||||
|
||||
svr.run();
|
||||
}
|
||||
|
||||
// vim: et ts=4 sw=4 cin cino={1s ff=unix
|
||||
|
Reference in New Issue
Block a user