From d3901aceae06697c5ec945ab3149213fca6b0108 Mon Sep 17 00:00:00 2001 From: Alex Hultman <3397140+alexhultman@users.noreply.github.com> Date: Mon, 18 Jun 2018 23:09:01 +0200 Subject: [PATCH] Create README.md --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a37dd46 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# v0.15 of µWebSockets + +v0.15 is a complete rewrite of µWS using µSockets as foundation. This leads to a much improved code base with real separation between this and that. It makes it possible to write plugins that only touches what they aim to change. Large performance improvements are inbound for small sends via better corking, and larger sends via proper streams support. SSL is supposed to be a first class citizen as well. + +## Focus on HTTP +* Stage 1: Focus on nailing fundamental HTTP(S). +* Stage 2: Better it with built-in router via `Hub::onHttpRoute` helper. +* Stage 3: Think about chunked responses (EventSource). + +#### Streams and helpers +HttpSockets are proper streams in v0.15 and do scale for large sends as well as for small ones. "Streams" are in/out per-socket-callbacks for giving or storing streamed data. +```c++ +uWS::defaultHub.onHttpRequest([buffer](HttpSocket *s, HttpRequest *req) { + + if (req->getUrl() == "/") { + s->writeStatus(200)->writeHeader("Server", "µWebSockets v0.15")->end(buffer, 512); + } else { + std::cout << "Got HTTP request at URL: " << req->getUrl() << std::endl; + } + +}).listen("localhost", 3000, 0).run(); +``` + +#### HTTP router helpers +Fast and simple routing should be added under Hub::onHttpRoute(lalala