You are looking at historical revision 16890 of this page. It may differ significantly from its current revision.
spiffy-request-vars provides easy access to variables from HTTP requests.
Thanks to DerGuteMoritz for the implementation of the content body reader and for several terminology suggestions (including the egg name). Also thanks to Peter Bex for the helpful discussions and lots of implementation suggestions.
Procedures[procedure] (request-vars #!key (source 'both) max-content-length)
request-vars returns a procedure which can be used to access variables from the HTTP request. The returned procedure takes the name of the variable (either a symbol or a string) as argument. You can (optionally) also pass a default value to be returned in case the variable is not set and an one-argument procedure to be used as a type converter for the variable value (e.g., string->number).
request-vars accepts some keyword arguments:
- 'query-string tells request-vars to parse the query string only (for GET variables). 'request-body tells request-vars to parse the request body only (e.g., for POST variables). 'both tells request-vars to parse both the request body and the query string. The default value for source is 'both. Notice that when 'both is used, variables from the request body have precedence over the ones from the query string.
- the maximum content length (in characters) to be read from the request body. Default is #f (no limit).
(let (($ (request-vars))) ($ 'var1) ($ 'var2 "") ;; if var12 is not set, return "" ($ 'var3 0 string->number)) ;; if var3 is not set, return 0; if it is ;; set, convert its value to a number
- Initial release