racket-route-match
1 route-match
2 route-compile
7.7

racket-route-match

junker

 (require racket-route-match)
  package: racket-route-match

URL route-matching library for Racket

Example of usage:

(require racket-route-match)
(require net/url)
(require web-server/servlet)
 
(route-match
  "/blog/:name/page/:page" "/blog/racket/page/2")
 
 
(route-match
  "/blog/:name/page/:page" "https://racket-lang.org/blog/racket/page/2")
 
 
(route-match
  "/blog/:name/page/:page" (string->url "/blog/racket/page/2"))
 
 
 
 
(route-match
  "/blog/*/page/:page" "/blog/racket/page/2")
 
 
(route-match
  "/blog/:name/page*/:page" "/blog/racket/page-super/2")
 
 
(route-match
  "/blog/:name/**/:page" "/blog/racket/super/buper/page/2")
 
 
 
 
(define req
  (make-request #"GET"
    (string->url "/blog/racket/page/2")
     empty (delay empty) #f "1.2.3.4" 80 "4.3.2.1"))
 
(route-match
  "/blog/:name/page/:page" (request-uri req))
 
 
 
 
(define user-route (route-compile "/blog/:name/page/:page"))
(route-match user-route "/blog/racket/page/2")
 
 
 
(define user-route (route-compile "/blog/:name/page/:page" '((page #px"\\d+"))))
(route-match user-route "/blog/racket/page/2")

    1 route-match

    2 route-compile

1 route-match

Matches route with URL

(define (route-match route request))

route - string with params (eg. "/blog/:name/page/:page" ) request - url for compare (eg. "/blog/racket/page/2")

2 route-compile

Compiles route for additional performance

(define (route-compile route [constraints '()]))

route - string with params (eg. "/blog/:name/page/:page" ) constraints - condition regexp for params (eg. ’((page #px"\\d+")) )