src/prologue/core/nativesettings

Source   Edit  

Types

CtxSettings = ref object
  mimeDB*: MimeDB
  config*: TableRef[string, StringTableRef]
Context settings. Source   Edit  
Settings = ref object
  address*: string           ## The address of socket.
  port*: Port                ## The port of socket.
  listener*: Socket          ## listening socket to use (nil to auto create)
  debug*: bool               ## Debug mode(true is yes).
  reusePort*: bool           ## Use socket port in multiple times.
  bufSize*: int              ## Buffer size of sending static files.
  ## Data which carries user defined settings.
  
Global settings for all handlers. Source   Edit  

Procs

func `[]`(settings: Settings; key: string): JsonNode {.inline,
    ...raises: [KeyError], tags: [], forbids: [].}
Retrieves value if key is in settings. Source   Edit  
func getOrDefault(settings: Settings; key: string): JsonNode {.inline,
    ...raises: [], tags: [], forbids: [].}
Retrieves value if key is in settings. Otherwise nil will be returned. Source   Edit  
func hasKey(settings: Settings; key: string): bool {.inline, ...raises: [],
    tags: [], forbids: [].}
Returns true if key is in settings. Source   Edit  
proc loadSettings(configPath: string): Settings {....raises: [KeyError,
    EmptySecretKeyError, IOError, OSError, JsonParsingError, ValueError],
    tags: [ReadIOEffect, WriteIOEffect], forbids: [].}
Creates a new Settings. Source   Edit  
func loadSettings(data: JsonNode): Settings {.
    ...raises: [KeyError, EmptySecretKeyError], tags: [], forbids: [].}
Creates a new Settings. Source   Edit  
func newCtxSettings(): CtxSettings {....raises: [], tags: [], forbids: [].}
Creates a new context settings. Source   Edit  
func newSettings(address = ""; port = Port(8080); debug = true;
                 reusePort = true; secretKey = randomString(8); appName = "";
                 bufSize = 40960; data: JsonNode = nil; listener: Socket = nil): Settings {.
    ...raises: [EmptySecretKeyError], tags: [RootEffect], forbids: [].}
Creates a new Settings. Source   Edit  
func newSettingsFromJsonNode(settings: var Settings; data: JsonNode) {.inline,
    ...raises: [KeyError, EmptySecretKeyError], tags: [], forbids: [].}
Source   Edit