恩。。的确像,DLang 开发效率快也是有据可查了。。
Hunt Framework 更简单获取用户 IP 的方法:
string ip = request.ip();
string client_ip() { import hunt.framework.http.Request; import std.array; if(request().headerExists("X-Forwarded-For")) { string ips = request().header("X-Forwarded-For"); auto arr = ips.split(","); if(arr.length >= 0) return arr[0]; } return request().clientAddress().toAddrString(); }
代码中可以添加一些注释吗?
这语法真心像php,哈哈哈。