chickadee » call-with-query » call-with-cgi-query

call-with-cgi-query quaerendumprocedure

Gather parameters (including post-variables, query-variables, cookies, server-variables) into an association-list when called as a CGI program.

quaerendum
A monadic function receiving a query parameter
(define (call-with-cgi-query quaerendum)
  (let ((environment
          (alist-map
            (lambda (key value) (cons (env-string->symbol key) value))
            (get-environment-variables))))
    (quaerendum
      (make-query
        environment
        (remove-null-artifacts
          (append
            (form-urldecode-environment environment 'http-cookie)
            (form-urldecode-environment environment 'http-cookie2)
            (form-urldecode-environment environment 'query-string)
            (form-urldecode-with-separator (read-all))))))))