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
:equal-route
:match-route)
(:import-from :alexandria
:delete-from-plist)
(:export :make-mapper
:connect
:next-route
@ -42,14 +44,12 @@
:name name
: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
(member-route mapper
(make-instance 'route
(apply #'make-instance route-class
:url url
:method method
:regexp regexp
:name name))))
(delete-from-plist args :route-class)))))
(defparameter *env* nil)

View file

@ -21,7 +21,7 @@
(handler :initarg :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))
(setf (route-rule route)
(make-rule url :method method :regexp regexp)))