mapping a url to a hunchentoot handler, use :param to replace the url
content, matching by cl-ppcre regex.
do not write a () in regex sides.
(map-routes
(get "/" index)
(get "/about" about)
(get "/wtd" get-handler)
(get "/test/:param1/and/:param2" test-params)
(get "/params/:id" show-params :id "\\d+")
(post "/threads/update/:id" update-test :id "\\d+")
(get "/category/:name/:page" show-category :name "\\w+" :page "\\d{2,5}")
(get "/articles/:year/:month/:day" show-articles :year "\\d{4}" :month "\\d{2}" :day "\\d{2}"))
;; add more routes
(add-route '(get "/more" more-handler))
;; ...
route template: (method “url/path/def” handler) (method “url/:param1/def/:param2” handler) (method “url/:param1/def/:param2” handler :param1 “\d{4}” :param2 “\w+”) ;; eg.
(get "/this/:route/with/:param" get-this :route "\\w+" :param "\\d+")
route and handler:
(map-routes
(get "/" home)
(get "/books/:id" show-book :id "\\d{8}")
(post "/books/update/:id" update-book :id "\\d{8}"))
;; use map-routes instead of add-route
(add-route '(get "/index" show-index))
(defun show-index ()
...)
;; if there are params
(defun show-book(params)
(let ((book-id (getf params :id)))
...))
;; start hunchentoot
;; use ht-acceptor instead of easy-acceptor
(hunchentoot:start (make-instance 'ht-routes:ht-acceptor :port 4242))