HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 11:34 UTC)
Re: HTTP request handler / middleware SRFI Shiro Kawai (05 Apr 2019 12:05 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 12:24 UTC)
Re: HTTP request handler / middleware SRFI Shiro Kawai (05 Apr 2019 17:45 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (05 Apr 2019 14:02 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 15:50 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (05 Apr 2019 15:58 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 16:19 UTC)
Re: HTTP request handler / middleware SRFI Peter (05 Apr 2019 16:47 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (05 Apr 2019 20:14 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 21:51 UTC)
Re: HTTP request handler / middleware SRFI Shiro Kawai (05 Apr 2019 19:02 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 13:11 UTC)
Re: HTTP request handler / middleware SRFI Peter (05 Apr 2019 13:20 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 13:38 UTC)
Re: HTTP request handler / middleware SRFI Peter (05 Apr 2019 13:58 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 15:18 UTC)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (05 Apr 2019 21:19 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (06 Apr 2019 00:08 UTC)
(missing)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (06 Apr 2019 05:31 UTC)
Re: HTTP request handler / middleware SRFI Peter (06 Apr 2019 07:30 UTC)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (06 Apr 2019 20:20 UTC)
Re: HTTP request handler / middleware SRFI John Cowan (06 Apr 2019 23:10 UTC)
Re: HTTP request handler / middleware SRFI Duy Nguyen (10 Sep 2019 14:12 UTC)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (10 Sep 2019 14:18 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (06 Apr 2019 08:24 UTC)

Re: HTTP request handler / middleware SRFI Peter 06 Apr 2019 07:30 UTC

> I looked at what Peter described above.  His API and mine have some
> similarities.  I like how his definitions allow specifying the types of URL
> parameters so that automatic conversion can happen.  Is there some place to
> look for more information on the return values?

There's no documentation, only the code right now. They can easily be
extended via `scgi:add-parameter-converter!'. I use that extensively,
for example:

(define-storable-structure <email-template>
  (id integer-or-false?)
  (name symbol?)
  (nice-name string?)
  (recipient string?)
  (category string?)
  (variables list?)
  (subject string?)
  (text string?))

(define (add-default-parameter-converter! name type)
  (scgi:add-parameter-converter! name
                                 (lambda (name value params)
                                   (if (and value
                                            (string? value)
                                            (every char-numeric? (string->list value))
                                            (number? (string->number value)))
                                       (load-record type (string->number value))
                                       #f))))

(add-default-parameter-converter! '<email-template> <email-template>)

-> (define-url-handler (get "/" foo bar (email-template <email-template>))
     ...)

The defaults are defined like this:

(scgi:add-parameter-converter! 'none (lambda (name value params) value))
(scgi:add-parameter-converter! 'boolean (lambda (name value params) (if value #t #f)))
(scgi:add-parameter-converter! 'number (lambda (name value params)
                                         (if value (string->number value) #f)))
(scgi:add-parameter-converter! 'symbol (lambda (name value params)
                                         (if value (string->symbol value) #f)))
(scgi:add-parameter-converter! 'character (lambda (name value params) (if value (string-ref value 0) #f)))
(scgi:add-parameter-converter! 'list (lambda (name value params)
                                       "Collect all parameters of the form NAME, put their values into a list. Drop empty strings."
                                       (filter (lambda (str)
                                                 (not (string-null? str)))
                                               (scgi:parameters name))))