awful paths as procedures pasted by mario-goulart on Thu May 17 01:58:52 2012

(use awful)

(define (ticket-id path)
  (and (string-prefix? "/ticket/" path)
       (and-let* ((tokens (string-split path "/"))
                  (_ (not (null? (cdr tokens))))
                  (id (string->number (cadr tokens))))
         (and id (list id)))))

(define-page ticket-id
  (lambda (id)
    (conc "This is ticket " id)))


(define (ticket-reporter+severity path)
  (and (string-prefix? "/ticket/" path)
       (and-let* ((tokens (string-split path "/"))
                  (_ (> (length tokens) 2)))
         (list (cadr tokens)
               (caddr tokens)))))

(define-page ticket-reporter+severity
  (lambda (reporter severity)
    (sprintf "Reporter=~a, severity=~a"
             reporter
             severity)))

Example of requests/responses added by mario-goulart on Thu May 17 02:01:21 2012

http://localhost:8080/ticket/42 => This is ticket 42
http://localhost:8080/ticket/mario => not found
http://localhost:8080/ticket/mario/low => Reporter=mario, severity=low