2015-09-19 01:49:23 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "speedy.hpp"
|
|
|
|
|
2015-09-21 04:21:50 +08:00
|
|
|
// TODO: still doesn't work
|
|
|
|
// debug the whole thing
|
|
|
|
void test(http::request_cb_t callback, speedy::Speedy &app) {
|
|
|
|
app.get("/test", callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto foo = [](http::Request& req, http::Response& res) {
|
|
|
|
res.send("foo");
|
|
|
|
};
|
|
|
|
|
2015-09-19 01:49:23 +08:00
|
|
|
int main(void)
|
|
|
|
{
|
2015-09-20 20:30:26 +08:00
|
|
|
uv::UvLoop loop;
|
2015-09-19 01:49:23 +08:00
|
|
|
http::Ipv4 ip("0.0.0.0", 3400);
|
2015-09-20 20:30:26 +08:00
|
|
|
|
|
|
|
speedy::Speedy app(loop, ip);
|
2015-09-21 04:21:50 +08:00
|
|
|
app.get("/foo", foo);
|
|
|
|
app.get("/bar", [](http::Request& req, http::Response& res) {
|
|
|
|
res.send("bar");
|
|
|
|
});
|
|
|
|
auto cb = [](http::Request& req, http::Response& res) {
|
|
|
|
res.send("test");
|
|
|
|
};
|
|
|
|
test(http::request_cb_t(cb), app);
|
|
|
|
|
2015-09-19 01:49:23 +08:00
|
|
|
app.listen();
|
|
|
|
|
2015-09-20 20:30:26 +08:00
|
|
|
loop.run(uv::UvLoop::Mode::Default);
|
|
|
|
|
2015-09-19 01:49:23 +08:00
|
|
|
return 0;
|
|
|
|
}
|