13.2 Query string from POST

The query string would be encoded in the HTTP body on the POST method.

There’s only a slight difference when you pass query string by POST instead of with GET: you don’t need a URL rule using a regex, so the "?" is unnecessary here.

(post "/there" #:from-post 'qstr
      (lambda (rc)
        (:from-post rc 'get "name")))

Please notice that #:from-post 'qstr is necessary when you’re trying to get data from POST. And you should use :from-post to get related data from query-string.

#:from-post <mode>

The mode includes:

The reason to design :from-post is for the efficient purpose. Artanis will not try to auto parse POST body as query-string for at least 2 reasons:

useful to avoid redundant parsing. However, each time you call :from-post, it will parse the query-string again, the correct way to fetch multiple values is:

(:from-post rc 'get-vals "key1" "key2" "key3")

;; For example:
;; let-values is imported from srfi-11
(let-values (((title sub-title old-passwd new-passwd)
              (:from-post rc 'get-vals "title" "sub-title"
                          "old-passwd" "new-passwd")))
  ..........
  )

BTW, you may get the parsed query-string as an assoc-list as well:

(let ((qstr (:from-post rc 'get)))
  (assoc-ref qstr "key-1"))