diff options
author | Konstantin Molchanov <moigagoo@live.com> | 2018-11-03 21:26:53 +0400 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-11-07 11:26:51 +0100 |
commit | d5e113c3a626d3c32eba39e513f08f0fc8f05bfe (patch) | |
tree | 98978b4929040ba7b5bf4684a9c498e036d35978 | |
parent | c2c05f5e724b8fe5380e6e45f3c1bcf48359915a (diff) | |
download | Nim-d5e113c3a626d3c32eba39e513f08f0fc8f05bfe.tar.gz |
Add readData proc that accepts a string.
-rw-r--r-- | lib/pure/cgi.nim | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/pure/cgi.nim b/lib/pure/cgi.nim index 101146ace..869abc9cc 100644 --- a/lib/pure/cgi.nim +++ b/lib/pure/cgi.nim @@ -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. |