Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

new function #'parse-route-url

  • Loading branch information...
commit f53d3a0ac6bb29e1f52d8b1303dd90792601b74a 1 parent aa35026
@archimag authored
Showing with 24 additions and 4 deletions.
  1. +1 −0  src/packages.lisp
  2. +23 −4 src/route.lisp
View
1  src/packages.lisp
@@ -20,6 +20,7 @@
#:genurl-submodule
#:genurl-with-host
#:redirect
+ #:parse-route-url
;; modules
#:define-module
#:define-initialization
View
27 src/route.lisp
@@ -77,12 +77,15 @@
(eval-when (:execute)
(reconnect-all-routes)))))
+(defun route-template-from-symbol (symbol submodule)
+ (concatenate 'list
+ (submodule-full-baseurl submodule)
+ (routes:parse-template (get symbol :template)
+ (get symbol :parse-vars))))
+
(defun create-route-from-symbol (symbol submodule)
(make-instance 'route
- :template (concatenate 'list
- (submodule-full-baseurl submodule)
- (routes:parse-template (get symbol :template)
- (get symbol :parse-vars)))
+ :template (route-template-from-symbol symbol submodule)
:symbol symbol
:content-type (or (get symbol :content-type)
(string-symbol-value +content-type-symbol+
@@ -144,3 +147,19 @@
(puri:render-uri uri nil)))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; parse url for route
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun parse-route-url (url route-symbol &optional submodule-symbol)
+ (let ((mapper (make-instance 'routes:mapper)))
+ (routes:connect mapper
+ (make-instance 'routes:route
+ :template (route-template-from-symbol route-symbol
+ (if submodule-symbol
+ (find-submodule submodule-symbol)
+ *submodule*))))
+ (multiple-value-bind (route bindings) (routes:match mapper url)
+ (if route
+ (alexandria:alist-plist bindings)))))
+
Please sign in to comment.
Something went wrong with that request. Please try again.