Fix
This commit is contained in:
parent
09c5a126be
commit
d20dbe2649
3 changed files with 5 additions and 5 deletions
|
@ -73,9 +73,9 @@ Routes are generated automatically from packages under `:example/routes`:
|
|||
|
||||
### Dynamic Routing
|
||||
|
||||
Dynamic routes use square brackets to indicate parameters. For example:
|
||||
Dynamic routes use `< >` to indicate parameters. For example:
|
||||
|
||||
`/src/routes/user/[id].lisp` → `/user/[id]`
|
||||
`/src/routes/user/<id>.lisp` → `/user/:id`
|
||||
|
||||
In the handlers, you can access the value of `id` through the `params` argument.
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
(regex-replace "/index$" path "")))
|
||||
|
||||
(defun bracket->colon (path)
|
||||
(regex-replace-all "\\[(.*?)\\]" path ":\\1"))
|
||||
(regex-replace-all "<(.*?)>" path ":\\1"))
|
||||
|
||||
(defun path->uri (path)
|
||||
(bracket->colon (remove-index path)))
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
(ok (string= (path->uri "/nested/index") "/nested")))
|
||||
|
||||
(testing "dynamic path"
|
||||
(ok (string= (path->uri "/user/[id]") "/user/:id"))
|
||||
(ok (string= (path->uri "/location/[country]/[city]") "/location/:country/:city" ))))
|
||||
(ok (string= (path->uri "/user/<id>") "/user/:id"))
|
||||
(ok (string= (path->uri "/location/<country>/<city>") "/location/:country/:city" ))))
|
||||
|
||||
(deftest package-test
|
||||
(testing "normal case"
|
||||
|
|
Loading…
Reference in a new issue