Skip to content

Instantly share code, notes, and snippets.

@yannick
Created February 3, 2016 20:49
Show Gist options
  • Select an option

  • Save yannick/1e6ae7d977c773b94fbe to your computer and use it in GitHub Desktop.

Select an option

Save yannick/1e6ae7d977c773b94fbe to your computer and use it in GitHub Desktop.
class Mylog
this(string timeid, ref HTTPServerRequest req)
{
this.timeid = timeid;
this.unixtime = Clock.currTime.toUnixTime();
this.domain = req.host;
this.ip = req.headers.get("X-Real-IP", req.headers.get("X-Forwarded-For", req.peer));
this.userAgent = req.headers.get("User-Agent", "");
foreach (key, val; req.headers)
{
import std.string : toLower;
if (!(key.toLower == "date")) //date is somewhat kaputt
this.headers[key] = val;
}
foreach (key, val; req.query)
{
this.query[key] = sanitize(val);
}
foreach (key, val; req.cookies)
{
this.cookies[key] = sanitize(val);
}
foreach (key, val; req.params)
{
this.parameters[key] = val;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment