import strutils, sockets, httpserver
var counter = 0
proc handleRequest(client: TSocket, path, query: string): bool {.procvar.} =
inc(counter)
client.send("Hello for the $#th time." % $counter & wwwNL)
return false # do not stop processing
run(handleRequest, TPort(80))
How would I get the body of a POST request or the ip address of the client? I can see they're part of the TServer type but I can't figure out how to get hold of them from within the handleRequest procedure.
Thanks.
It seems that run is a bit limited.
However, run is simply a shortcut to the following:
var server: TServer
open(server)
while true:
server.next()
if server.reqMethod == "POST": echo("Got body, ", server.body)
Hope this helps.
Thanks again dom96
There's a lot of functionality packed into Nimrod's Pure libraries and the fact they can be compiled for multiple platforms and do not depend on any external shared libraries is brilliant. I really want to get to know Nimrod even if I'm off to a stuttering start so I genuinely do appreciate your help.