web/cookie: improvements: create-from-keys, more default values
This commit is contained in:
parent
1e6ffc1fa2
commit
b4fc8ad05d
2 changed files with 10 additions and 7 deletions
|
@ -3,14 +3,18 @@
|
|||
(defpackage :scopes/web/cookie
|
||||
(:use :common-lisp)
|
||||
(:local-nicknames (:c cl-cookie))
|
||||
(:export #:create #:make-header))
|
||||
(:export #:create #:create-from-keys #:make-header))
|
||||
|
||||
(in-package :scopes/web/cookie)
|
||||
|
||||
(defun create (name value &key max-age (path "/") (httponly-p t))
|
||||
(c:make-cookie :name name :value value
|
||||
:path path :httponly-p httponly-p
|
||||
:max-age max-age))
|
||||
(defun create (name value &rest args &key &allow-other-keys)
|
||||
(apply #'create-from-keys :name name :value value args))
|
||||
|
||||
(defun create-from-keys (&key name value domain (same-site :lax)
|
||||
(max-age 86400) (path "/") (httponly-p t)
|
||||
&allow-other-keys)
|
||||
(c:make-cookie :name name :value value :domain domain :same-site same-site
|
||||
:max-age max-age :path path :httponly-p httponly-p))
|
||||
|
||||
(defun make-header (cookie)
|
||||
(c:write-set-cookie-header cookie))
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
(shape:print-fields ia s 'messages))
|
||||
|
||||
(defun render-cookie (cdata)
|
||||
(let ((cookie (cookie:create (getf cdata :name) (getf cdata :value))))
|
||||
(let ((cookie (apply #'cookie:create-from-keys cdata)))
|
||||
(cookie:make-header cookie)))
|
||||
;"DEMO=1234567_value; Path=/") ;"; Domain=testing.cyberscopes.org")
|
||||
|
||||
;;;; response definitions
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue