aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-05-05 07:24:40 -0700
committercolin <colin@cicadas.surf>2024-05-05 07:24:40 -0700
commit1e4235bb162a44bc9474c2fe4851724c41d827a6 (patch)
tree103f3cef9fed93b538db177062ad783cfa9d4f4b /examples
parent57afcdd8b437b3ca9b66126db966d07ed751ed15 (diff)
Fix: route-builder constructor; Modify: dice roller [example]
Diffstat (limited to 'examples')
-rw-r--r--examples/dice-roller.lisp17
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))))