Rough skeleton for proper HTTP parsing

This commit is contained in:
Alex Hultman
2018-06-26 21:48:22 +02:00
parent 879ab8a5de
commit aea255f72c
5 changed files with 210 additions and 72 deletions
+9
View File
@@ -30,10 +30,19 @@ int main(int argc, char **argv) {
app.onGet("/", [](auto *s, auto *req, auto *args) {
// streams need to expose more information about lifetime!
s->writeStatus("200 OK")->write([](int offset) {
return std::string_view(buffer.data() + offset, buffer.length() - offset);
}, buffer.length());
}).onPost("/upload", [](auto *s, auto *req, auto *args) {
s->read([s](std::string_view chunk) {
std::cout << "Received chunk on URL /upload: <" << chunk << ">" << std::endl;
s->writeStatus("200 OK")->end("Thanks for posting!");
});
}).onWebSocket("/wsApi", []() {
}).listen("localhost", 3000, 0);