diff --git a/config.lisp b/config.lisp index ea0972c..b6d95e8 100644 --- a/config.lisp +++ b/config.lisp @@ -7,7 +7,7 @@ (:local-nicknames (:util :scopes/util)) (:export #:base #:root #:*root* #:*current* #:env-data #:env-keys #:env-prefix #:env-path #:from-env #:path - #:actions #:add #:add-action #:children #:env-slots + #:actions #:add #:add-action #:add-actions #:children #:env-slots #:name #:setup #:parent #:shutdown)) (in-package :scopes/config) @@ -85,6 +85,10 @@ (setf handler #'(lambda (ctx msg) (apply handler ctx msg params)))) (push (list pattern handler) (actions cfg))) +(defun add-actions (&rest acts) + (dolist (act acts) + (apply #'add-action (car act) (cadr act) (cddr act)))) + ;;;; utility functions (defun from-env (key default) diff --git a/core/core.lisp b/core/core.lisp index 54612ea..a57a1ba 100644 --- a/core/core.lisp +++ b/core/core.lisp @@ -118,11 +118,11 @@ ;;;; some simple predefined actions -(defun echo (ctx msg) +(defun echo (ctx msg &key (domain :scopes) (action :echo)) (let ((sndr (message:sender msg))) (if sndr (let* ((h (shape:head msg)) - (new-msg (message:create `(:scopes :echo ,@(cddr h)) + (new-msg (message:create `(,domain ,action ,@(cddr h)) :data (shape:data msg)))) (send sndr new-msg)) (util:lgw "sender missing" msg)))) diff --git a/test/etc/config-web.lisp b/test/etc/config-web.lisp index f9b4f37..a3f28d2 100644 --- a/test/etc/config-web.lisp +++ b/test/etc/config-web.lisp @@ -17,7 +17,9 @@ `((("hx") server:message-handler :html-responder cs-hx:response) (() server:fileserver :doc-root ,(t:test-path "" "docs")))) -(config:add-action '(:test :data) #'core:echo) +(config:add-actions + '((:test :data) core:echo) + '((:test :cookie) server:set-cookie)) (config:add :client :class 'client:config diff --git a/test/test-web.lisp b/test/test-web.lisp index 8c4d3a8..2640d8c 100644 --- a/test/test-web.lisp +++ b/test/test-web.lisp @@ -69,5 +69,8 @@ (deftest test-message (client) (let ((msg (message:create '(:test :data :field :info) :data '(:info "test data")))) (== (client:send-message client msg) - "