Skip to content

Commit

Permalink
Merge pull request #4 from Frechmatz/defrest-documentation
Browse files Browse the repository at this point in the history
Added documentation to parse-schema
  • Loading branch information
bonkzwonil committed May 27, 2016
2 parents b1ec8d3 + 3b72da8 commit 5b26274
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions defrest.lisp
Expand Up @@ -82,6 +82,21 @@


(defun parse-schema (schema)
"splits a schema into blocks representing it's static parts and it's placeholders.
Example 1:
'/test/{id:[a-z]+}' => ('/test/' (:KEY 'id' :REGEXP '[a-z]+'))
Example 2:
'/test/{id:[a-z]?[0-9]+}' => ('/test/' (:KEY 'id' :REGEXP '[a-z]?[0-9]+'))
Example 3:
'/album/{album:[a-z]+}/track/{track:[0-9]+}' => ('/album/' (:KEY 'album' :REGEXP '[a-z]+') '/track/' (:KEY 'track' :REGEXP '[0-9]+'))
Example 4:
'/album/{album:[a-z]+}/track/{vol:[0-9]+}-{pos:[0-9]+}' => ('/album/' (:KEY 'album' :REGEXP '[a-z]+') '/track/'
(:KEY 'vol' :REGEXP '[0-9]+') '-' (:KEY 'pos' :REGEXP '[0-9]+'))
"
(mapcar #'(lambda (x)
(if (scan "{.+:.+}" x)
(multiple-value-bind (n/a found)
Expand Down

0 comments on commit 5b26274

Please sign in to comment.