debug.scm 854 B

123456789101112131415161718192021222324252627282930
  1. (library (templates debug)
  2. (export debug-table-template)
  3. (import
  4. (except (rnrs base) let-values error)
  5. (only (guile)
  6. lambda* λ
  7. ;; input output
  8. with-output-to-string
  9. display
  10. write)
  11. ;; standard web library
  12. (web request)
  13. (web response)
  14. (web uri)))
  15. (define debug-table-template
  16. (λ (request body)
  17. `((h1 "hello world!")
  18. (table
  19. (tr (th "header") (th "value"))
  20. ;; splice in all request headers
  21. ,@(map (lambda (pair)
  22. `(tr (td (tt ,(with-output-to-string
  23. (lambda () (display (car pair))))))
  24. (td (tt ,(with-output-to-string
  25. (lambda ()
  26. (write (cdr pair))))))))
  27. (request-headers request))))))