aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-24 09:27:48 -0600
committerColin Okay <okay@toyful.space>2022-02-24 09:27:48 -0600
commit02874f575215f9665d99943a79541d4f849d50c3 (patch)
tree4c2f368f9079d7f054be337aab3d3ae15fbeedcf
parentefd69e5fcaf0f825d85b1202d337a1a8ba47ef28 (diff)
added server domain. set-cookie uses it if available.
-rw-r--r--lazybones-hunchentoot.asd2
-rw-r--r--lazybones-hunchentoot.lisp31
-rw-r--r--lazybones.asd2
-rw-r--r--package.lisp1
4 files changed, 23 insertions, 13 deletions
diff --git a/lazybones-hunchentoot.asd b/lazybones-hunchentoot.asd
index c44e927..4167cff 100644
--- a/lazybones-hunchentoot.asd
+++ b/lazybones-hunchentoot.asd
@@ -4,7 +4,7 @@
:description "hunchentoot backend for lazybones"
:author "Colin Okay <okay@toyful.space>"
:license "AGPLv3"
- :version "0.1.2"
+ :version "0.2.0"
:serial t
:depends-on (#:hunchentoot #:lazybones)
:components ((:file "lazybones-hunchentoot")))
diff --git a/lazybones-hunchentoot.lisp b/lazybones-hunchentoot.lisp
index bb47d27..d39968f 100644
--- a/lazybones-hunchentoot.lisp
+++ b/lazybones-hunchentoot.lisp
@@ -41,7 +41,14 @@
:accessor canned-responses
:initarg :canned-responses
:initform nil
- :documentation "an alist of (CODE CONTENT-FUNCTION CONTENT-TYPE)"))
+ :documentation "an alist of (CODE CONTENT-FUNCTION CONTENT-TYPE)")
+ (domain
+ :accessor server-domain
+ :initarg :domain
+ :initform nil
+ :documentation "A specific domain to associate with this server
+ for the purposes of cookie handling. NIL by default, which is
+ fine."))
(:default-initargs
:address "127.0.0.1"))
@@ -82,7 +89,7 @@
;;; SERVER FUNCTIONS
-(defun create-server (&key (port 8888) (address "127.0.0.1"))
+(defun create-server (&key (port 8888) (address "127.0.0.1") )
"Creates an opaque server on port PORT, and returns it. Servers are
backend specific, but each may be passed in to INSTALL-APP,
UNINSTALL-APP, START-SERVER, and STOP-SERVER."
@@ -256,15 +263,17 @@ the value of the Content-Type request header."
(name value
&key expires max-age path domain secure http-only (response lzb:*response*))
"Sets the response cookie"
- (h:set-cookie name
- :value value
- :expires expires
- :max-age max-age
- :path path
- :domain domain
- :secure secure
- :http-only http-only
- :reply response))
+ (apply 'h:set-cookie name
+ :value value
+ :reply response
+ (nconc (when expires (list :expires expires))
+ (when max-age (list :max-age max-age))
+ (when path (list :path path))
+ (cond
+ (domain (list :domain domain))
+ (server-domain (list :domain (server-domain))))
+ (when secure (list :secure secure))
+ (when http-only (list :http-only http-only)))))
(defun http-respond (content &optional (code 200))
"Final step preparing response before backend does the rest. For
diff --git a/lazybones.asd b/lazybones.asd
index fcbce22..da9d921 100644
--- a/lazybones.asd
+++ b/lazybones.asd
@@ -4,7 +4,7 @@
:description "http route handling"
:author "Colin Okay <okay@toyful.space>"
:license "AGPLv3"
- :version "0.8.0"
+ :version "0.9.0"
:serial t
:depends-on (#:alexandria
#:str
diff --git a/package.lisp b/package.lisp
index 716c250..b11af58 100644
--- a/package.lisp
+++ b/package.lisp
@@ -27,6 +27,7 @@
#:install-app
#:uninstall-app
#:create-server
+ #:server-domain
#:start-server
#:stop-server
#:canned-response