hello-world.scm 634 B

12345678910111213141516171819202122
  1. (library (handlers hello-world)
  2. (export hello-world-handler)
  3. (import
  4. (except (rnrs base) let-values error)
  5. (only (guile)
  6. lambda* λ)))
  7. (define hello-world-handler
  8. (lambda (request request-body)
  9. "A handler for a route."
  10. ;; A handler must return 2 values: The header and body
  11. ;; of the response.
  12. (values
  13. ;; Return the headers as first value (the bare
  14. ;; minimum).
  15. '((content-type . (text/plain)))
  16. ;; Then the response body. This is an example for
  17. ;; returning a string as second value, instead of a
  18. ;; procedure, which takes an output port.
  19. "Hello World!")))