From ddbdb583e0cb309db5d5b03cc5bcf5216951d389 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Tue, 8 Feb 2022 11:20:25 -0600 Subject: changing route variable syntax --- lazybones.lisp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lazybones.lisp') diff --git a/lazybones.lisp b/lazybones.lisp index 3345afe..148cd05 100644 --- a/lazybones.lisp +++ b/lazybones.lisp @@ -238,9 +238,9 @@ ENDPOINT's handler function." (defun parse-route-string-template (template) "Routes are of the form -/foo/bar/<>/blah +/foo/bar/:variable:/blah -/foo/bar/<>/blah +/foo/bar/:var parse-integer:/blah On success returns things like: @@ -267,20 +267,20 @@ Returns NIL on failure" collect (string-downcase field))))) (defun parse-route-variable-string (string) - "A route variable string looks like <> or <> + "A route variable string looks like :foo: or :foo bar: In the case of a successful parse, a list of one or two symbols is returned. These symbosl are created using read-from-string, which allows for these symbols' packages to be specified if desired. Returns NIL on failure." - (when (and (a:starts-with-subseq "<<" string) - (a:ends-with-subseq ">>" string)) + (when (and (a:starts-with-subseq ":" string) + (a:ends-with-subseq ":" string)) (destructuring-bind (var-name . decoder?) (re:split " +" (string-trim " " - (subseq string 2 (- (length string) 2)))) + (subseq string 1 (- (length string) 1)))) (if decoder? (list (string-upcase var-name) (read-from-string (first decoder?))) (list (string-upcase var-name)))))) -- cgit v1.2.3