Welcome to the CHICKEN Scheme pasting service
MVC? added by mario-goulart on Thu Feb 9 00:35:16 2012
$ cat mvc.scm (use awful regex) (include "controllers.scm") (include "routes.scm") $ cat controllers.scm (define (patient-edit path) (let* ((route (alist-ref 'patient-edit routes)) (matcher (route-matcher route)) (patient-id (and-let* ((match (string-match matcher path))) (pathname-file (car match))))) (++ "Editing patient " patient-id))) $ cat routes.scm (define-record route matcher handler) (define routes `((patient-edit . ,(make-route (regexp "/patients/edit/[0-9]+") patient-edit)))) (define (set-routes!) (for-each (lambda (route) (define-page (route-matcher route) (route-handler route))) (map cdr routes))) (set-routes!) $ awful mvc.scm ;; http://localhost:8080/patients/edit/123