Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2014 23:29
Show Gist options
  • Save anonymous/9698670 to your computer and use it in GitHub Desktop.
Save anonymous/9698670 to your computer and use it in GitHub Desktop.
template for iterator
iterator pairs*(s: TSession, request: TRequest, response:PResponse): tuple[key, value: string] =
## iterates over every (key, value) pair in the session `s`.
var sessionId: string
sessionId = getSessionId(request, response)
var list = session.redisCon.hGetAll("session:" & sessionId)
if not isNil(list):
var i = 0
while i < list.len and not isNil(list[i]):
yield (list[i], list[i+1])
i = i + 2
template data*(s: TSession): expr =
bind pairs, session
session.pairs(request, response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment