ordo/examples/interceptor.scm

31 lines
971 B
Scheme

(use-modules
(ice-9 filesystem)
(logging logger)
(ordo connection)
(ordo interceptor)
(ordo interceptor tmp-dir)
(ordo interceptor debug)
(ordo action filesystem)
(ordo logger))
(define chain
(list (connection-interceptor (local-connection))
(tmp-dir-interceptor #:tmp-dir)
(interceptor
"install hello"
#:enter (lambda (ctx)
(fs:install-file (context-connection ctx)
(file-name-join* (var-ref ctx #:tmp-dir) "hello.txt")
#:content "Hello, world!\n"))
#:register #:hello)
(interceptor
"stat hello"
#:enter (lambda (ctx)
(fs:stat (context-connection ctx) (var-ref ctx #:hello)))
#:register #:hello-stat)
(debug-vars-interceptor #:hello #:hello-stat)
(debug-vars-interceptor)))
(setup-logging #:level 'INFO)
(execute (init-context) chain)
(shutdown-logging)