mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-13 03:26:30 +00:00
Add missing config file
This commit is contained in:
parent
9d9bd10e15
commit
d0ee8e8403
1 changed files with 23 additions and 0 deletions
23
src/config.nim
Normal file
23
src/config.nim
Normal file
|
@ -0,0 +1,23 @@
|
|||
import parsecfg except Config
|
||||
import os, net, types, strutils
|
||||
|
||||
proc get[T](config: parseCfg.Config; s, v: string; default: T): T =
|
||||
let val = config.getSectionValue(s, v)
|
||||
if val.len == 0: return default
|
||||
|
||||
when T is int: parseInt(val)
|
||||
elif T is bool: parseBool(val)
|
||||
elif T is string: val
|
||||
|
||||
proc getConfig*(path: string): Config =
|
||||
var cfg = loadConfig(path)
|
||||
|
||||
Config(
|
||||
address: cfg.get("Server", "address", "0.0.0.0"),
|
||||
port: cfg.get("Server", "port", 8080),
|
||||
title: cfg.get("Server", "title", "Nitter"),
|
||||
staticDir: cfg.get("Server", "staticDir", "./public"),
|
||||
|
||||
cacheDir: cfg.get("Cache", "directory", "/tmp/nitter"),
|
||||
profileCacheTime: cfg.get("Cache", "profileMinutes", 10)
|
||||
)
|
Loading…
Reference in a new issue