mike/helpers/request

Source   Edit  

Procs

proc body(ctx: Context): string {.inline, ...raises: [], tags: [], forbids: [].}
Gets the request body from the request Returns an empty string if the user sent no bodyt Source   Edit  
proc getHeader(ctx: Context; key, default: string): string {....raises: [KeyError],
    tags: [], forbids: [].}
Gets a header from the request with key and returns default if it cannot be found Source   Edit  
proc getHeader(ctx: Context; key: string): string {....raises: [KeyError],
    tags: [], forbids: [].}
Source   Edit  
proc getHeaders(ctx: Context; key: string): seq[string] {....raises: [KeyError],
    tags: [], forbids: [].}
Returns all values for a header. Use this if the request contains multiple headers with the same key. Returns empty if header doesn't exist Source   Edit  
proc hasBody(ctx: Context): bool {....raises: [], tags: [], forbids: [].}
Returns true if the request has a body Source   Edit  
proc hasHeader(ctx: Context; key: string): bool {....raises: [], tags: [],
    forbids: [].}
Returns true if the request has header with key Source   Edit  
proc headers(ctx: Context): HttpHeaders {....raises: [], tags: [], forbids: [].}
Returns Headers for a request Source   Edit  
proc httpMethod(ctx: Context): HttpMethod {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc json(ctx: Context): JsonNode {....raises: [IOError, OSError, JsonParsingError,
    ValueError], tags: [ReadIOEffect, WriteIOEffect], forbids: [].}
Parses JSON from the requests body and returns that Source   Edit  
proc json[T](ctx: Context; to: typedesc[T]): T
Parses JSON from the requests body and then converts it into T Source   Edit  
proc optBody(ctx: Context): Option[string] {.inline, ...raises: [], tags: [],
    forbids: [].}
Returns the request body from the request Source   Edit