On Monday, 30 October 2017 at 17:23:02 UTC, Daniel Kozak wrote:
Maybe this one:
import vibe.d;
import std.regex;
import std.array : appender;
static reg = ctRegex!"^/greeting/([a-z]+)$";
void main()
{
setupWorkerThreads(logicalProcessorCount);
runWorkerTaskDist(&runServer);
runApplication();
}
void runServer()
{
auto settings = new HTTPServerSettings;
settings.options |= HTTPServerOption.reusePort;
settings.port = 3000;
settings.serverString = null;
listenHTTP(settings, &handleRequest);
}
void handleRequest(HTTPServerRequest req,
HTTPServerResponse res)
{
switch(req.path)
{
case "/": res.writeBody("Hello World", "text/plain");
break;
default:
auto m = matchFirst(req.path, reg);
string message = "Hello, ";
auto app = appender(message);
app.reserve(32);
app ~= m[1];
res.writeBody(app.data, "text/plain");
}
}
On Mon, Oct 30, 2017 at 5:41 PM, ade90036 via Digitalmars-d <
[email protected]> wrote:
On Thursday, 21 September 2017 at 13:09:33 UTC, Daniel Kozak
wrote:
wrong version, this is my letest version:
https://paste.ofcode.org/qWsQi kdhKiAywgBpKwANFR
On Thu, Sep 21, 2017 at 3:01 PM, Daniel Kozak
<[email protected]> wrote:
my version: https://paste.ofcode.org/RLX7GM6SHh3DjBBHd7wshj
On Thu, Sep 21, 2017 at 2:50 PM, Sönke Ludwig via
Digitalmars-d < [email protected]> wrote:
Am 21.09.2017 um 14:41 schrieb Vadim Lopatin:
[...]
Oh, sorry, I forgot the reusePort option, so that multiple
sockets can listen on the same port:
auto settings = new HTTPServerSettings("0.0.0.0:3000");
settings.options |= HTTPServerOption.reusePort;
listenHTTP(settings, &handleRequest);
Hi, would it be possible to re-share the example of vibe.d
woth multithreaded support.
The pastebin link has expired and the pull request doesnt have
the latest version.
Thanks
Ade
I tried to run the example, and I'm struck with a linker error
DMD v2.076.1 and LDC 1.4.0.
03-11-2017 11:34:16 arun-desk-r7
~/code/personal/d/simple-web-benchmark
$ dub run --root=d --compiler=dmd --build=release --config=dmd
Fetching libevent 2.0.2+2.0.16 (getting selected version)...
Fetching diet-ng 1.4.3 (getting selected version)...
Fetching taggedalgebraic 0.10.7 (getting selected version)...
Fetching openssl 1.1.5+1.0.1g (getting selected version)...
Fetching botan 1.12.9 (getting selected version)...
Fetching memutils 0.4.9 (getting selected version)...
Fetching vibe-d 0.8.2-alpha.2 (getting selected version)...
Fetching vibe-core 1.2.1-alpha.2 (getting selected version)...
Fetching libasync 0.8.3 (getting selected version)...
Fetching botan-math 1.0.3 (getting selected version)...
Fetching eventcore 0.8.20 (getting selected version)...
Package vibe-core can be upgraded from 1.2.1-alpha.2 to
1.3.0-alpha.2.
Package eventcore can be upgraded from 0.8.20 to 0.8.21.
Use "dub upgrade" to perform those changes.
Performing "release" build using dmd for x86_64.
vibe-d:utils 0.8.2-alpha.2: building configuration "library"...
vibe-d:data 0.8.2-alpha.2: building configuration "library"...
immutable(ubyte)[]
vibe-d:core 0.8.2-alpha.2: building configuration "libevent"...
immutable(ubyte)[]
vibe-d:crypto 0.8.2-alpha.2: building configuration "library"...
diet-ng 1.4.3: building configuration "library"...
vibe-d:stream 0.8.2-alpha.2: building configuration "library"...
vibe-d:textfilter 0.8.2-alpha.2: building configuration
"library"...
vibe-d:inet 0.8.2-alpha.2: building configuration "library"...
vibe-d:tls 0.8.2-alpha.2: building configuration "notls"...
vibe-d:http 0.8.2-alpha.2: building configuration "library"...
immutable(ubyte)[]
vibe-d:mail 0.8.2-alpha.2: building configuration "library"...
vibe-d:mongodb 0.8.2-alpha.2: building configuration "library"...
vibe-d:redis 0.8.2-alpha.2: building configuration "library"...
immutable(ubyte)[]
vibe-d:web 0.8.2-alpha.2: building configuration "library"...
vibe-d 0.8.2-alpha.2: building configuration "libevent"...
vibedtest ~master: building configuration "dmd"...
Linking...
/usr/bin/ld: cannot find -levent
/usr/bin/ld: cannot find -levent_pthreads
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
dmd failed with exit code 1.
03-11-2017 11:35:10 arun-desk-r7
~/code/personal/d/simple-web-benchmark
$