dlang-tour / english

Base language version of the Tour
https://tour.dlang.org
28 stars 73 forks source link

vibed/web-server.md code example build error. #355

Open VGeo opened 3 years ago

VGeo commented 3 years ago

The WEB Server example building fails with

source/app.d(51,9): Error: invalid `foreach` aggregate `req.headers`, define `opApply()`, range primitives, or use `.tupleof`

DMD64 D Compiler v2.097.2, vibe.d 0.9.3

Could be fixed with byKeyValue() method:

foreach(key, value; req.headers.byKeyValue()) {
Hume2 commented 2 years ago

It happens with DMD 2.100.0 also. Additionally, it requires to cast the variable username_ to string using cast(string)username_.