response.rkt 823 B

123456789101112131415161718192021222324252627
  1. #lang racket
  2. (require
  3. web-server/servlet-env
  4. web-server/servlet)
  5. (provide (all-defined-out))
  6. ;; expects a string
  7. (define (make-response #:code [code 200]
  8. #:message [message #"OK"]
  9. #:seconds [seconds (current-seconds)]
  10. #:mime-type [mime-type TEXT/HTML-MIME-TYPE]
  11. #:headers [headers (list (make-header #"Cache-Control" #"no-cache"))]
  12. content)
  13. ;;(display "CONTENT:") (displayln content)
  14. ;;(display "string?:") (displayln (string? content))
  15. (response/full code
  16. message
  17. seconds
  18. mime-type
  19. headers
  20. (list (string->bytes/utf-8 content))))
  21. (define (send-success-response rendered-page)
  22. (make-response rendered-page))