By making the routes: seq[Route] public it's possible to create Router elements in different files and combine them later.
fileA.nim
import
mummy, mummy/routers
var contractsRouter*: Router
contractsRouter.get("/contracts/api/items", routeContractsApiItems)
contractsRouter.get("/contracts/api/approvals", routeContractsApiApprovals)
fileB.nim
import
mummy, mummy/routers
var personRouter*: Router
personRouter.get("/person/api/names", routePersonApiNames)
personRouter.get("/person/api/emails", routePersonApiEmails)
fileC.nim
import
mummy, mummy/routers
import
./fileA,
./fileB
var mainRouter: Router
mainRouter.get("/", routeMain)
mainRouter.get("/login", routeMainLogin)
for route in contractsRouter.routes:
mainRouter.route.add(route)
for route in personRouter.routes:
mainRouter.route.add(route)
let server = newServer(mainRouter)
server.serve(Port(8080))
By making the
routes: seq[Route]
public it's possible to createRouter
elements in different files and combine them later.fileA.nim
fileB.nim
fileC.nim