Allow to specify ':route-class' for 'find-route'.

This commit is contained in:
Eitaro Fukamachi 2014-10-24 17:46:21 +09:00
parent f565b360e3
commit 7be263e80a
2 changed files with 7 additions and 7 deletions

View file

@ -14,6 +14,8 @@
:route-handler :route-handler
:equal-route :equal-route
:match-route) :match-route)
(:import-from :alexandria
:delete-from-plist)
(:export :make-mapper (:export :make-mapper
:connect :connect
:next-route :next-route
@ -42,14 +44,12 @@
:name name :name name
:handler fn))) :handler fn)))
(defun find-route (mapper url &key (method '(:GET)) regexp name) (defun find-route (mapper url &rest args &key method regexp name (route-class 'route) &allow-other-keys)
(car (car
(member-route mapper (member-route mapper
(make-instance 'route (apply #'make-instance route-class
:url url :url url
:method method (delete-from-plist args :route-class)))))
:regexp regexp
:name name))))
(defparameter *env* nil) (defparameter *env* nil)

View file

@ -21,7 +21,7 @@
(handler :initarg :handler (handler :initarg :handler
:accessor route-handler))) :accessor route-handler)))
(defmethod initialize-instance :after ((route route) &rest initargs &key url method regexp &allow-other-keys) (defmethod initialize-instance :after ((route route) &rest initargs &key url (method '(:GET)) regexp &allow-other-keys)
(declare (ignore initargs)) (declare (ignore initargs))
(setf (route-rule route) (setf (route-rule route)
(make-rule url :method method :regexp regexp))) (make-rule url :method method :regexp regexp)))