summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Shangreaux <shoshin@cicadas.surf>2023-01-24 22:02:17 -0600
committerGrant Shangreaux <shoshin@cicadas.surf>2023-01-24 22:02:17 -0600
commitffa213f6f825479df7b544f23d1240dd1c86f10f (patch)
treeed62fb361048774e252c7a1f80c1da325bc8a7de
parent01c9197114270d153308226a1588de78ed05ee29 (diff)
Add: doorkeeper :message param to pass info to user
Basic handling for when a hero name is entered but does not exist in the store. The /tavern-door endpoint will parse a NAME query param and the doorkeeper says they've never heard of them.
-rw-r--r--dnd.asd3
-rw-r--r--endpoints.lisp11
-rw-r--r--pages.lisp4
3 files changed, 12 insertions, 6 deletions
diff --git a/dnd.asd b/dnd.asd
index d192838..bd4c74b 100644
--- a/dnd.asd
+++ b/dnd.asd
@@ -17,7 +17,8 @@
#:parenscript
#:derrida
#:ironclad
- #:jonathan)
+ #:jonathan
+ #:quri)
:components ((:file "package")
(:file "utilities")
(:file "init")
diff --git a/endpoints.lisp b/endpoints.lisp
index 5c2a656..19be125 100644
--- a/endpoints.lisp
+++ b/endpoints.lisp
@@ -14,8 +14,9 @@
(defendpoint* :get "/" () ()
(redirect-to "/tavern-door"))
-(defendpoint* :get "/tavern-door" () ()
- (doorkeeper))
+(defendpoint* :get "/tavern-door" ((name str)) ()
+ (if name (doorkeeper :message (format nil "M'fraid I've n'er 'eard o' ~a." name))
+ (doorkeeper)))
(defendpoint* :post "/tavern-door" () ()
(with-plist ((name :name)) (lzb:request-body)
@@ -24,7 +25,7 @@
(lzb:set-response-cookie +session-cookie-name+ (session-id sesh)
:path "/" :domain "localhost")
(redirect-to "/tavern"))
- (redirect-to "/tavern-door"))))
+ (redirect-to (format nil "/tavern-door?name=~a" (quri:url-encode name))))))
(defendpoint* :get "/godess-shrine" () ()
(godess-shrine))
@@ -40,6 +41,10 @@
(with-hero-session (hero)
(tavern hero)))
+(defun str (string)
+ "A String"
+ string)
+
(defun redirect-to (location)
"Set the lazybones response header and response code for redirecting to LOCATION.
This procedure will error if lazybones:*request* is not currently bound."
diff --git a/pages.lisp b/pages.lisp
index 9ae2de9..7f705cd 100644
--- a/pages.lisp
+++ b/pages.lisp
@@ -19,9 +19,9 @@
(:input :name "NAME")
(:button :type "submit" "Pray To The Goddess"))))
-(defun doorkeeper ()
+(defun doorkeeper (&key (message "Wot's yer name 'ero?"))
(with-page (:title "Tavern Door")
- (:h1 "Wot's yer name 'ero?")
+ (:h1 message)
(:form :method "POST" :action "/tavern-door"
(:label :for "NAME" "Thy Hero's Appelation:")
(:input :name "NAME")