Am 26.07.2013 14:52, schrieb Manu Evans:

On Fri, 26 Jul 2013 12:12:11 GMT, Sönke Ludwig wrote:

You also have req.form.get("xyz", null) which does exactly that (see http://dlang.org/hash-map.html). Since this is standard D AA behavior, I didn't want to deviate from that potentially creating confusion.
Upon further consideration, I'm not sure I agree this is a good idea.
I tend to think web dev should be as friction-less as possible, and this is a rather pointless point of friction...
I can see where you're coming from, but I'm not sure I agree. Getting form/url args is a fundamental operation.

Perhaps it might be interesting if you supported opDispatch? I found myself even getting annoyed at having to type req.form["xyz"]. The whole [""] thing is unnatural to type quickly (at least for me), and it looks pretty noisy. 'req.form.xyz' would be pretty nice!

That would indeed be nice, but the question is which of the two is
usually desired?

string opDispatch(string field)() const {
    return m_aa.get(field, null);
}

or

string opDispatch(string field)() const {
    auto p = field in m_aa;
    enforceHTTP(p !is null, HTTPStatus.badRequest,
        "Request missing form field "~field);
    return *p;
}

One related thing you might want to look at is the vibe.http.form
module, which automatically maps form fields to function parameters. It
is not yet in a final state though and I think has some documentation
errors. But in theory that would be the most friction-less way to handle
form requests. I'll start using it for a project in the near future and
will improve it along the way.