diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dice-roller.lisp | 17 |
1 files changed, 13 insertions, 4 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)))) |