Changeset 17219 in project


Ignore:
Timestamp:
02/09/10 14:23:45 (10 years ago)
Author:
Mario Domenech Goulart
Message:

Documentation for spiffy-request-vars 0.2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/spiffy-request-vars

    r16890 r17219  
    1212
    1313
    14 === Procedures
     14=== Procedures and macros
    1515
    1616<procedure>(request-vars #!key (source 'both) max-content-length)</procedure>
     
    2424; {{max-content-length}} : the maximum content length (in characters) to be read from the request body.  Default is {{#f}} (no limit).
    2525
     26==== Example
    2627
    27 ==== Usage example
    28 
     28<enscript highlight=scheme>
    2929  (let (($ (request-vars)))
    3030    ($ 'var1)
     
    3232    ($ 'var3 0 string->number)) ;; if var3 is not set, return 0; if it is
    3333                                ;; set, convert its value to a number
     34</enscript>
     35
     36
     37<macro>(with-request-vars (var1 var2 ... varN) expr1 expr2 ... exprN)</macro>
     38
     39Bind the given identifiers to the corresponding query string and request body variable values and evaluate the expressions.
     40
     41==== Example
     42
     43<enscript highlight=scheme>
     44(with-request-vars (a b c)
     45   (conc "a = " a
     46         "b = " b
     47         "c = " c))
     48</enscript>
     49
     50
     51<macro>(with-request-vars* getter (var1 var2 ... varN) expr1 expr2 ... exprN)</macro>
     52
     53The same as {{with-request-vars}} but requires the HTTP variables getter (the return value of {{request-vars}}) as the first argument.  It's useful for situations when you already have the getter and don't want to reparse the query string and request body.  With {{with-request-vars*}}, the given getter will be used and no reparsing will be performed.
     54
     55==== Example
     56
     57<enscript highlight=scheme>
     58(let (($ (request-vars)))
     59  (with-request-vars* $ (a b c)
     60     (conc "a = " a
     61           "b = " b
     62           "c = " c)))
     63</enscript>
    3464
    3565
     
    4878=== Version history
    4979
     80; 0.2 : Added {{with-request-vars}} and {{with-request-vars*}}
    5081; 0.1 : Initial release
Note: See TracChangeset for help on using the changeset viewer.