aboutsummaryrefslogtreecommitdiff
path: root/lazybones-hunchentoot.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lazybones-hunchentoot.lisp')
-rw-r--r--lazybones-hunchentoot.lisp31
1 files changed, 20 insertions, 11 deletions
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