How to return user name from vibed session?

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 10 05:34:02 PST 2015


On Thursday, 10 December 2015 at 13:23:29 UTC, Suliman wrote:

>
> But question about why I need to get session info like:
>
> writeln("USER Session: ", req.session.get!string("username"));
>
> is still actual.

When you have a template that looks like this:

V get(V, K)(K key) {...}

The compiler is able to deduce the type of K because of the 
argument 'key'. However, there's no way for it to know what V 
should be. You have to tell it explicitly when you instantiate it:

auto str = get!string("key1");
auto i = get!int("key2");


More information about the Digitalmars-d-learn mailing list