ordo/examples/interceptor.scm

32 lines
971 B
Scheme
Raw Normal View History

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