Thread overview
Web servers in D
Sep 02
Seb
Sep 02
bauss
Sep 02
bauss
Sep 12
aberba
August 25
What libraries are people using to run webservers other than vibe.d?

Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd.

I think for D to a have good web story it needs to appeal to serious backend developers, not hipsters who go after fads (mongodb is a fad, jade/haml is a fad).

I probably need to combine several libraries, but the features I'm looking for are:

- Spawn an HTTP server listening on a port, and routing requests to functions/delegates, without hiding the details of the http request/response objects (headers, cookies, etc).

- Support for websockets

- Runs delegates in fibers/coroutines

- Basic database connectivity (No "orm" needed; just raw sql).

- When iterating the result set of a sql query, has the ability to automatically map each row against a struct, and throw if the structure does not match.

- More generally, map any arbitrary object (such as json) to a struct. Something like Zewo/Reflection package for swift[0].

[0]: https://github.com/Zewo/Reflection

I feel like Vibe.d satisfies my first 3 requirements, but for the rest I will probably have to look for something else.
August 25
On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote:
> What libraries are people using to run webservers other than vibe.d?
>
> Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd.
>
> I think for D to a have good web story it needs to appeal to serious backend developers, not hipsters who go after fads (mongodb is a fad, jade/haml is a fad).
>
> I probably need to combine several libraries, but the features I'm looking for are:
>
> - Spawn an HTTP server listening on a port, and routing requests to functions/delegates, without hiding the details of the http request/response objects (headers, cookies, etc).
>
> - Support for websockets
>
> - Runs delegates in fibers/coroutines
>
> - Basic database connectivity (No "orm" needed; just raw sql).
>
> - When iterating the result set of a sql query, has the ability to automatically map each row against a struct, and throw if the structure does not match.
>
> - More generally, map any arbitrary object (such as json) to a struct. Something like Zewo/Reflection package for swift[0].
>
> [0]: https://github.com/Zewo/Reflection
>
> I feel like Vibe.d satisfies my first 3 requirements, but for the rest I will probably have to look for something else.

There is collie [1]. Never used. Can't say a lot about it.

arsd [2] has a lot of interesting web stuff: event loop, FastCGI/SimpleCGI; web-, DOM-, mail-utilities.

And the last but not least I'm running currently a small web server serving static files based on tanya [3]. Once I'm ready to write a web-framework on top of it, it would be what you mention: no compile-time templates, no jade-style templates, since I dislike these too. But unfortunately it is not something can be used now.

[1] https://github.com/huntlabs/collie
[2] https://github.com/adamdruppe/arsd
[3] https://github.com/caraus-ecms/tanya
August 25
On Friday, 25 August 2017 at 06:15:35 UTC, Eugene Wissner wrote:
>
> There is collie [1]. Never used. Can't say a lot about it.
>
> arsd [2] has a lot of interesting web stuff: event loop, FastCGI/SimpleCGI; web-, DOM-, mail-utilities.
>
> And the last but not least I'm running currently a small web server serving static files based on tanya [3]. Once I'm ready to write a web-framework on top of it, it would be what you mention: no compile-time templates, no jade-style templates, since I dislike these too. But unfortunately it is not something can be used now.
>
> [1] https://github.com/huntlabs/collie
> [2] https://github.com/adamdruppe/arsd
> [3] https://github.com/caraus-ecms/tanya

Thanks. Those are some interesting links.

FWIW I kind of like compile-time templates. I just don't like jade (or coffee-script, or stylus, or all these languages that try to remove the punctuation and curly braces, and all signs of structure).
August 25
On 2017-08-25 07:25, Hasen Judy wrote:
> What libraries are people using to run webservers other than vibe.d?
> 
> Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd.
> 
> I think for D to a have good web story it needs to appeal to serious backend developers, not hipsters who go after fads (mongodb is a fad, jade/haml is a fad).

Why would a backend developer care about front end stuff like jade/haml? Just don't use those parts ;)

> I probably need to combine several libraries, but the features I'm looking for are:
> 
> - Spawn an HTTP server listening on a port, and routing requests to functions/delegates, without hiding the details of the http request/response objects (headers, cookies, etc).
> 
> - Support for websockets
> 
> - Runs delegates in fibers/coroutines
> 
> - Basic database connectivity (No "orm" needed; just raw sql).

It depends on which database you need to connect to. For PostgreSQL there's ddb [1] and for MySQL there's mysql-native [2].

> - When iterating the result set of a sql query, has the ability to automatically map each row against a struct, and throw if the structure does not match.

I don't know about mysql-native, but for ddb you can use the PGCommand class and the executeQuery or executeRow to execute the query and specify the struct that should be returned.

> - More generally, map any arbitrary object (such as json) to a struct. Something like Zewo/Reflection package for swift[0].

vibe.d has built-in support for serialization [3].

> [0]: https://github.com/Zewo/Reflection
> 
> I feel like Vibe.d satisfies my first 3 requirements, but for the rest I will probably have to look for something else.

[1] http://code.dlang.org/packages/ddb
[2] http://code.dlang.org/packages/mysql-native
[3] http://vibed.org/api/vibe.data.serialization

-- 
/Jacob Carlborg
September 02
On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote:
> What libraries are people using to run webservers other than vibe.d?
>
> Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd.
>
> I think for D to a have good web story it needs to appeal to serious backend developers, not hipsters who go after fads (mongodb is a fad, jade/haml is a fad).
>
> I probably need to combine several libraries, but the features I'm looking for are:
>
> - Spawn an HTTP server listening on a port, and routing requests to functions/delegates, without hiding the details of the http request/response objects (headers, cookies, etc).
>
> - Support for websockets
>
> - Runs delegates in fibers/coroutines
>
> - Basic database connectivity (No "orm" needed; just raw sql).
>
> - When iterating the result set of a sql query, has the ability to automatically map each row against a struct, and throw if the structure does not match.
>
> - More generally, map any arbitrary object (such as json) to a struct. Something like Zewo/Reflection package for swift[0].
>
> [0]: https://github.com/Zewo/Reflection
>
> I feel like Vibe.d satisfies my first 3 requirements, but for the rest I will probably have to look for something else.

> Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd.

Don't use these components :-)

> - Spawn an HTTP server listening on a port, and routing requests to functions/delegates, without hiding the details of the http request/response objects (headers, cookies, etc).

Vibe.d does this - just don't use the automatic API generation feature if you don't like it.  Note, you can get access to the request/response objects even if you do use the API generation by using an @before method.  E.g. in an interface you may have something like this:

@method(HTTPMethod.POST)
@before!getRequestInfo("requestInfo")
@property Token login(LoginRequestMeta login, RequestInfo requestInfo);

And then define your getRequestInfo method like this:

static RequestInfo getRequestInfo(HTTPServerRequest req, HTTPServerResponse res)
{
	RequestInfo requestInfo;
	requestInfo.headers = req.headers;
	requestInfo.ipAddress = req.clientAddress.toAddressString();
	requestInfo.userAgent = requestInfo.headers.get("User-Agent", "");
	
	return requestInfo;
}

In this case I've grabbed the ip address and user agent of the user, but you could also grab cookies etc.

> - When iterating the result set of a sql query, has the ability to automatically map each row against a struct, and throw if the structure does not match.

You can do this with MySQL Native whilst using vibe.d.  You might do something like this:

Prepared prepared = prepare(this.conn, sql);
prepared.setArgs(params);

auto row = prepared.queryRow();

if (row.isNull()) {
    throw new Exception("Query returned an empty row");
}

T item;
try {
    row.toStruct!T(item);
} catch(Exception e) {

}

Where T is your struct type that you're trying to convert the row to.

As for the template language, you could try:
http://code.dlang.org/packages/diamond
https://github.com/repeatedly/mustache-d
There are probably others.

September 02
On Saturday, 2 September 2017 at 09:26:27 UTC, Andrew Chapman wrote:
> On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote:
>> [...]
>
>> [...]
>
> Don't use these components :-)
>
>> [...]
>
> Vibe.d does this - just don't use the automatic API generation feature if you don't like it.  Note, you can get access to the request/response objects even if you do use the API generation by using an @before method.  E.g. in an interface you may have something like this:

There is built-in support for authentication in vibe.d:

https://github.com/rejectedsoftware/vibe.d/tree/master/examples/web-auth
September 02
On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote:
> What libraries are people using to run webservers other than vibe.d?
>
> Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd.
>
> I think for D to a have good web story it needs to appeal to serious backend developers, not hipsters who go after fads (mongodb is a fad, jade/haml is a fad).
>
> I probably need to combine several libraries, but the features I'm looking for are:
>
> - Spawn an HTTP server listening on a port, and routing requests to functions/delegates, without hiding the details of the http request/response objects (headers, cookies, etc).
>
> - Support for websockets
>
> - Runs delegates in fibers/coroutines
>
> - Basic database connectivity (No "orm" needed; just raw sql).
>
> - When iterating the result set of a sql query, has the ability to automatically map each row against a struct, and throw if the structure does not match.
>
> - More generally, map any arbitrary object (such as json) to a struct. Something like Zewo/Reflection package for swift[0].
>
> [0]: https://github.com/Zewo/Reflection
>
> I feel like Vibe.d satisfies my first 3 requirements, but for the rest I will probably have to look for something else.

Here is another template engine that can be used along with vibe. I actually made it for the same reason you don't wanna use vibe. Because I didn't like the template language and I was more familiar with razor templates from ASP.NET

https://github.com/bausshf/Diamond
September 02
On Saturday, 2 September 2017 at 20:18:17 UTC, bauss wrote:
> On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote:
>> [...]
>
> Here is another template engine that can be used along with vibe. I actually made it for the same reason you don't wanna use vibe. Because I didn't like the template language and I was more familiar with razor templates from ASP.NET
>
> https://github.com/bausshf/Diamond

To add onto this you can use mysql-native with vibe.d.

https://github.com/mysql-d/mysql-native
September 12
On Saturday, 2 September 2017 at 09:26:27 UTC, Andrew Chapman wrote:
>
>> [...]
>
> Don't use these components :-)
>
>> [...]
>
> Vibe.d does this - just don't use the automatic API generation feature if you don't like it.  Note, you can get access to the request/response objects even if you do use the API generation by using an @before method.  E.g. in an interface you may have something like this:
>
> [...]

Thanks for your response. I didn't see the new replies because I wrote the original message before I signed up on the site forum (I'm using the site, not an email program).
September 12
On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote:
> What libraries are people using to run webservers other than vibe.d?
>
> Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd.
>
> I think for D to a have good web story it needs to appeal to serious backend developers, not hipsters who go after fads (mongodb is a fad, jade/haml is a fad).
>
> I probably need to combine several libraries, but the features I'm looking for are:
>
> - Spawn an HTTP server listening on a port, and routing requests to functions/delegates, without hiding the details of the http request/response objects (headers, cookies, etc).
>
> - Support for websockets
>
> - Runs delegates in fibers/coroutines
>
> - Basic database connectivity (No "orm" needed; just raw sql).
>
> - When iterating the result set of a sql query, has the ability to automatically map each row against a struct, and throw if the structure does not match.
>
> - More generally, map any arbitrary object (such as json) to a struct. Something like Zewo/Reflection package for swift[0].
>
> [0]: https://github.com/Zewo/Reflection
>
> I feel like Vibe.d satisfies my first 3 requirements, but for the rest I will probably have to look for something else.

In 2017, backend developers are more likely to write microservices which expose rest/graphQL APIs and put them in dockers containers.... Unless you're a full stack developer, you'll not be using jade/diet (at least not enough to be tempted to use something else).

Its still sucks there's no object storage api for D. Are you guys still building monolithic web servers?