Skip to content

A mummy router that captures parts of the url + static files

Notifications You must be signed in to change notification settings

enthus1ast/nimMatchingMummyRouter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A mummy router that captures parts of the url

The documentation for matching syntax (for now)

import mummy
import matchingMummyRouter
var router: MatchRouter

proc getOneRecordHandler(request: Request, mt: MatchTable) =
  var headers: HttpHeaders
  headers["Content-Type"] = "text/plain"
  echo "MATCH RECORD: ", mt["id"]
  request.respond(200, headers, $mt["id"])

proc dumpHandler(request: Request, mt: MatchTable) =
  var headers: HttpHeaders
  headers["Content-Type"] = "text/plain"
  request.respond(200, headers, $mt)


router.post("/api/v1/record/@id:int", getOneRecordHandler)
router.get("/api/v1/recordGET/@id:int", getOneRecordHandler)

# Shows all different datatypes, matches on:
# /yes/-1337/23/21.42/foo
router.get("/@mybool:bool/@myint:int/@myabsint:absint/@myfloat:float/@mystring:string", dumpHandler)

# Serve all static files from the static folder:
router.get("/static/**", staticFileHandler)

let server = newServer(router)
server.serve(Port(9090))

About

A mummy router that captures parts of the url + static files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages