aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-11-26 08:44:36 -0800
committercolin <colin@cicadas.surf>2023-11-26 08:44:36 -0800
commit5aeff682246be07bf13c7c50f7899d790de3ad5b (patch)
tree900d8f71226dec93bf7c91b139ff823046ae30d2
parentf0aed2231f077a05f3bcb95cf332dd75866dc9aa (diff)
http-redirectHEADmain
-rw-r--r--src/client/parenscript.lisp7
-rw-r--r--src/lazybones.lisp7
-rw-r--r--src/package.lisp1
3 files changed, 13 insertions, 2 deletions
diff --git a/src/client/parenscript.lisp b/src/client/parenscript.lisp
index 2b393bc..141c9cd 100644
--- a/src/client/parenscript.lisp
+++ b/src/client/parenscript.lisp
@@ -2,7 +2,8 @@
(:use #:cl)
(:local-nicknames (#:lzb #:lazybones)
(#:a #:alexandria))
- (:export #:generate))
+ (:export #:generate
+ #:generate-js))
(in-package :lazybones/client.parenscript)
@@ -142,7 +143,7 @@ is the value of the endpoint's DISPATCH-PATTERN slot."
(gensym "MODULE"))
(module-name
- (intern (lispify (symbol-name (lzb::app-name app)))))
+ (intern (lispify (concatenate 'string "-" (symbol-name (lzb::app-name app))))))
(defuns
(loop :for ep :in (lzb:app-endpoints app)
@@ -161,3 +162,5 @@ is the value of the endpoint's DISPATCH-PATTERN slot."
,module)
(ps:create)))))
+(defun generate-js (app)
+ (eval `(ps:ps ,(generate app))))
diff --git a/src/lazybones.lisp b/src/lazybones.lisp
index d993f1d..d1e186e 100644
--- a/src/lazybones.lisp
+++ b/src/lazybones.lisp
@@ -462,6 +462,13 @@ making a new one if not."
"Singals an HTTP-ERROR with code and content."
(signal 'http-error :content content :code code))
+(defun http-redirect (location)
+ "Set the lazybones response header and response code for redirecting to LOCATION.
+This procedure will error if lazybones:*response* is not currently bound."
+ (setf (response-header :location) location
+ (response-code) "303"))
+
+
;;; MANAGING DEFINITIONS
diff --git a/src/package.lisp b/src/package.lisp
index 3ef4dcc..ca8c1b0 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -68,6 +68,7 @@
#:let-parameters
#:map-parameters
#:http-err
+ #:http-redirect
#:http-respond
#:install-app
#:request-body