Types
BodyData = TableRef[string, string]
SomeBodyData = Option[BodyData]
Procs
proc getBodyData[T: BodyData | JsonNode](req: var Request; dataType: typedesc[T]): Option[ T]
- Returns the body data from Request as JsonNode
proc getBodyDataJson(req: var Request): SomeBodyData {....raises: [], tags: [], forbids: [].}
-
Returns the body fields from Request. When called for the first time it will decode the body and store the result in BodyData table.
Note this must be called only when the provided body is JSON. Invalid JSON will be rejected and the returned value will be none.
proc getClientId(req: var Request): Option[string] {....raises: [KeyError], tags: [TimeEffect], forbids: [].}
- Returns the client-side ssid from Request
proc getFieldsJson(req: Request): JsonNode {....raises: [], tags: [], forbids: [].}
proc getFieldsTable(req: var Request): SomeBodyData {.inline, ...raises: [], tags: [], forbids: [].}
- An alias of getSomeBodyData
proc getFieldsTableJson(req: var Request): SomeBodyData {.inline, ...raises: [], tags: [], forbids: [].}
- An alias of getBodyDataJson
proc getQueryTable(req: var Request): TableRef[string, string] {.inline, ...raises: [], tags: [], forbids: [].}
- Retrieve query parameters as a table
proc getRequestBody(req: var Request): string {....raises: [], tags: [], forbids: [].}
- Retrieves Request body
proc getSessionCookie(req: var Request): ref Cookie {....raises: [KeyError], tags: [TimeEffect], forbids: [].}
- Returns the client-side ssid Cookie from Request
proc getSomeBodyData(req: var Request): SomeBodyData {....raises: [], tags: [], forbids: [].}
-
Returns the body fields from Request. When called for the first time it will decode the body and store the result in BodyData table.
If BodyData is already set, it will return the existing table.
Macros
macro go(id: untyped)
- Redirects to a specific GET route using the controller identifier.
macro go(id: untyped; params: typed)
- Redirects to a specific GET route using the controller identifier. This macro adds support for redirecting with query parameters.
macro newController(name, body: untyped)
Templates
template ctrl(name, body: untyped)
template isAuth(): bool
template redirectTo(controllerIdentName: typed)
- An alias of go macro that redirects to specific GET route using the controller name.
template storage(path: string): string
Exports
-
getHeader, findHeader, getUrl, getQuery, getIp, send, getUriPath, getBrowserName, getPlatform, getClientData, hasCookies, send, getCookies, send, getBody, $, getAgent, Request, getHttpMethod, getHeaders, getDefault, sendJson, getContentType, emptyResponseBody, getHeaders, resp, redirect, json, Response, getBody, redirect301, toString, respond, setCode, redirectUri, setBody, addHeader, respond, getCode, streamFile