aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/dice-roller.lisp17
-rw-r--r--src/endpoint.lisp4
2 files changed, 15 insertions, 6 deletions
diff --git a/examples/dice-roller.lisp b/examples/dice-roller.lisp
index 403ed55..3cd6ac3 100644
--- a/examples/dice-roller.lisp
+++ b/examples/dice-roller.lisp
@@ -1,6 +1,7 @@
(defpackage #:dice-roller
(:use #:cl)
- (:import-from #:weekend #:endpoint #:handle))
+ (:local-nicknames
+ (#:wknd #:weekend)))
(in-package #:dice-roller)
@@ -10,15 +11,17 @@
((rolls
:reader rolls
:initarg :rolls
+ :initform (wknd::slot-required 'roller 'rolls)
:type integer
:documentation "The number of rolls")
(sides
:reader sides
:initarg :sides
+ :initform (wknd:slot-required 'roller 'rolls)
:type integer
:documentation "The number of sides"))
(:documentation "")
- (:metaclass endpoint)
+ (:metaclass wknd::endpoint)
(:method . :get)
(:route-parts "roll" +digits+ "d" +digits+)
(:extractors (:rolls parse-integer) (:sides parse-integer))
@@ -31,9 +34,15 @@
(loop :repeat rolls :sum (1+ (random sides))))))
(defvar *server* (make-instance 'hunchentoot:easy-acceptor
- :port 8080))
+ :port 8888))
(hunchentoot:start *server*)
-;; now visit http://localhost:8080/roll/10/d/4
+;; now visit http://localhost:8888/roll/10/d/4
+(ql:quickload :dexador)
+
+(defun get-roll (rolls sides)
+ (dexador:get
+ (concatenate 'string "http://localhost:8888"
+ (wknd::route-to 'roller :rolls rolls :sides sides))))
diff --git a/src/endpoint.lisp b/src/endpoint.lisp
index a0d8f1d..81fdf74 100644
--- a/src/endpoint.lisp
+++ b/src/endpoint.lisp
@@ -203,10 +203,10 @@ extractors." part))))
(setf build-parts (nreverse build-parts))
(setf (route-builder class)
(lambda (kwargs)
- (apply #'concatenate 'string
+ (format nil "~{~a~}"
(loop :for part :in build-parts
:when (keywordp part)
- :do (assert (getf kwargs part) () "path needs ~s" part)
+ :do (assert (getf kwargs part) (kwargs) "path needs ~s" part)
:and :collect (getf kwargs part)
:else
:collect part))))))