Re: Trying to make dict in dict (table in table)

2019-10-08 Thread vbxx3
import net import strutils import tables import asynchttpserver, asyncdispatch type Server* = object port: int routes: Table[string, Table[string, proc(request: Request) {.cdecl.}]] allowedMethods: seq[string] proc newServer*: Server =

Re: Trying to make dict in dict (table in table)

2019-10-08 Thread vbxx3
Hi! httpMethod is string here

Re: Trying to make dict in dict (table in table)

2019-10-07 Thread vbxx3
What I need is { "GET": { "/path1": handler1, "/path2": handler2 }, "POST": { "/path3": handler3, "/path4": handler4 } } Run

Trying to make dict in dict (table in table)

2019-10-07 Thread vbxx3
type Server* = object port: int routes: Table[string, Table[string, proc(request: Request) {.cdecl.}]] allowedMethods: seq[string] proc newServer*: Server = result.port = 8080 result.allowedMethods = @["GET", "POST"] result.routes = initTable

Re: Passing procedure as argument

2019-10-06 Thread vbxx3
proc addRoute*(self: Server, httpMethod, route: string, handler: proc(request: Request) {.cdecl.}) = discard Run Well, it works, thanks :)

Passing procedure as argument

2019-10-06 Thread vbxx3
proc addRoute*(self: Server, httpMethod, route: string, handler: ???) discard Run What type do I need to set to pass the procedure as a handler?