Interpreting Parameters

Interpreting Parameters

WebGate represents request parameters as a hash table with string keys and passes them to the resource handler as its last argument. However, some requests contain complex parameters with type and header information and any request parameter can occur multiple times with different values, hence WebGate doesn't use simple strings as values in the parameters table but rather lists of instances of the message structure that has a SRFI-99 definition similar to this one:

  (define-record-type message
    #f #t
    type headers

The type field holds the content type of the message, headers contains an association list of headers and body contains the actual payload data as a string.

To access textual data conveniently, there is a synthetic accessor message-text that returns the message body iff it has a text/plain content type.

The helpers parameter-list-ref and parameter-ref allow you to extract a list of parameter values or a single value from a hash table. They take the hash table, a string key and an optional converter from message records to the desired target type as arguments. The message converter defaults to message-text.