Skip to content

Commit

Permalink
Added query proc to get query string of request
Browse files Browse the repository at this point in the history
  • Loading branch information
ajusa authored and dom96 committed Jan 22, 2022
1 parent 3e128fe commit cd886a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions jester/request.nim
Expand Up @@ -55,6 +55,19 @@ proc path*(req: Request): string =
let u = req.req.url
return u.path

proc query*(req: Request): string =
## Query string of request
when useHttpBeast:
let p = req.req.path.get("")
let queryStart = p.find('?')
if likely(queryStart != -1):
return p[queryStart .. ^1]
else:
return ""
else:
let u = req.req.url
return u.query

proc reqMethod*(req: Request): HttpMethod =
## Request method, eg. HttpGet, HttpPost
when useHttpBeast:
Expand Down
1 change: 1 addition & 0 deletions readme.markdown
Expand Up @@ -167,6 +167,7 @@ Request* = ref object
pathInfo*: string ## This is ``.path`` without ``.appName``.
secure*: bool
path*: string ## Path of request.
query*: string ## Query string of request.
cookies*: StringTableRef ## Cookies from the browser.
ip*: string ## IP address of the requesting client.
reqMeth*: TReqMeth ## Request method, eg. HttpGet, HttpPost
Expand Down

0 comments on commit cd886a3

Please sign in to comment.