Add readData proc that accepts a string.

This commit is contained in:
Konstantin Molchanov 2018-11-03 21:26:53 +04:00 • committed by Andreas Rumpf
commit d5e113c3a6

View file

@ -147,6 +147,12 @@ proc readData*(allowedMethods: set[RequestMethod] =
for name, value in decodeData(allowedMethods):
result[name.string] = value.string
proc readData*(data: string): StringTableRef =
## Read CGI data from a string.
result = newStringTable()
for name, value in decodeData(data):
result[name.string] = value.string
proc validateData*(data: StringTableRef, validKeys: varargs[string]) =
## validates data; raises `ECgi` if this fails. This checks that each variable
## name of the CGI `data` occurs in the `validKeys` array.