diff options
author | Grant Shangreaux <shoshin@cicadas.surf> | 2023-01-24 22:02:17 -0600 |
---|---|---|
committer | Grant Shangreaux <shoshin@cicadas.surf> | 2023-01-24 22:02:17 -0600 |
commit | ffa213f6f825479df7b544f23d1240dd1c86f10f (patch) | |
tree | ed62fb361048774e252c7a1f80c1da325bc8a7de | |
parent | 01c9197114270d153308226a1588de78ed05ee29 (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.asd | 3 | ||||
-rw-r--r-- | endpoints.lisp | 11 | ||||
-rw-r--r-- | pages.lisp | 4 |
3 files changed, 12 insertions, 6 deletions
@@ -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." @@ -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") |