web/client: add cookie-jar handling
This commit is contained in:
parent
923982369e
commit
dd69b1b56f
2 changed files with 6 additions and 3 deletions
|
@ -6,7 +6,7 @@
|
|||
:version "0.0.1"
|
||||
:homepage "https://www.cyberconcepts.org"
|
||||
:description "Web client and server functionality."
|
||||
:depends-on (:clack :dexador :flexi-streams
|
||||
:depends-on (:cl-cookie :clack :dexador :flexi-streams
|
||||
:lack :lack-component :lack-app-file :quri
|
||||
:scopes-core)
|
||||
:components ((:file "frontend/cs-hx" :depends-on ("web/dom" "web/response"))
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
(in-package :scopes/web/client)
|
||||
|
||||
(defvar *cookie-jar* (cl-cookie:make-cookie-jar))
|
||||
|
||||
(defclass config (config:base)
|
||||
((config:setup :initform #'core:default-setup)
|
||||
(base-url :reader base-url :initarg :base-url :initform "http://localhost:8135")
|
||||
|
@ -25,14 +27,15 @@
|
|||
(let* ((cfg (core:config ctx))
|
||||
(path (getf (shape:data msg) :path))
|
||||
(url (str:concat (base-url cfg) (doc-path cfg) path)))
|
||||
(dex:get url :headers '(("Accept". "text/html")))))
|
||||
(dex:get url :headers '(("Accept". "text/html")) :cookie-jar *cookie-jar*)))
|
||||
|
||||
(defun send-message (ctx msg)
|
||||
(let* ((cfg (core:config ctx))
|
||||
(url (str:concat (base-url cfg) (api-path cfg) (msgpath msg))))
|
||||
(dex:post url
|
||||
:content (data-as-alist (shape:data msg))
|
||||
:headers `(("Accept" . ,(accept cfg))))))
|
||||
:headers `(("Accept" . ,(accept cfg)))
|
||||
:cookie-jar *cookie-jar*)))
|
||||
|
||||
(defun msgpath (msg)
|
||||
(str:join "/" (loop for p in (shape:head msg)
|
||||
|
|
Loading…
Add table
Reference in a new issue