mike/helpers/request

  Source   Edit

Procs

proc body(ctx: Context): string {....raises: [KeyError, ValueError], tags: [].}
Gets the request body from the request Returns an empty string if the user sent no body   Source   Edit
proc getHeader(ctx: Context; key, default: string): string {....raises: [KeyError],
    tags: [].}
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: [].}
  Source   Edit
proc getHeaders(ctx: Context; key: string): seq[string] {....raises: [KeyError],
    tags: [].}
Returns all values for a header. Use this if the request contains multiple headers with the same key   Source   Edit
proc hasBody(ctx: Context): bool {....raises: [KeyError, ValueError], tags: [].}
Returns true if the request has a body   Source   Edit
proc hasHeader(ctx: Context; key: string): bool {....raises: [KeyError], tags: [].}
Returns true if the request has header with key   Source   Edit
proc httpMethod(ctx: Context): HttpMethod {....raises: [], tags: [].}
  Source   Edit
proc json(ctx: Context): JsonNode {....raises: [IOError, OSError, JsonParsingError,
    ValueError, Exception, KeyError], tags: [ReadIOEffect, WriteIOEffect].}
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] {....raises: [KeyError, ValueError],
    tags: [].}
Returns the request body from the request. Not really that useful but exists if you want to use it   Source   Edit