What is your favorite D feature?

Seb via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 21 19:53:05 PDT 2017


On Thursday, 22 June 2017 at 01:42:10 UTC, Brad Anderson wrote:
> A very simple vibe app could be added using dub's single-file 
> package format.

Hmm this is a great idea, but it wouldn't be "runnable" on the 
web.
Here's a PR for discussion:

https://github.com/dlang/dlang.org/pull/1763

> Something like (I haven't tried this):

You can even go more minimal - the following works:

#!/usr/bin/env dub
/+ dub.sdl:
name "hello_vibed"
dependency "vibe-d" version="~>0.8.0-rc.1"
versions "VibeDefaultMain"
+/
import vibe.d;

shared static this() @safe
{
     auto settings = new HTTPServerSettings;
     settings.port = 8080;
     listenHTTP(settings, (req, res) {
         res.writeBody("Hello, World: " ~ req.path);
     });
}


More information about the Digitalmars-d mailing list