[racket-dev] form:binding / request utilities

2011-03-04 Thread John Clements
I'm doing a web-server/insta example in class, and one of my students (Arlo 
White, cc:'ed) pointed out that  the existing framework for extracting bindings 
seems to be missing a bunch of useful functions. In particular, he volunteered 
to implement a few of the functions from the Spring framework, most notably a 
function that accepts a request and a name and returns the string associated 
with that name in the request's bindings.  Like hash-ref, it would allow you to 
specify your own failure behavior.

I've run into this myself, and it's always a pain to operate on the request 
structures.  Would you be open to adding a few functions like this to the 
web-server (if we provide them, along with docs and tests)? Looking at the 
documentation, it appears that there's some cleanup that just never made it to 
the top of someone's list.

John



smime.p7s
Description: S/MIME cryptographic signature
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Re: [racket-dev] form:binding / request utilities

2011-03-04 Thread Jay McCarthy
That sounds reasonable. Here are a few things:

1) I almost exclusively use formlets, where these issues are basically
taken care of. I suggest checking them out.

2) Would it be good for the request struct to be a prop:dict where the
dictionary is the bindings? Would that be confusing because it is also
plausible to dictionary on the headers?

3) Part of what you want is just request-bindings, but
request-bindings has lots of subtle bugs. For example, HTTP does not
mandate UTF-8, so naive conversion to Racket strings can crash. HTTP
differentiates between form bindings and file bindings---for files you
definitely want the bytes and you should also be able to get the
filename.

4) The docs are in web-server/scribblings/http.scrbl; The tests are in
tests/web-server/private/request-test.rkt and
tests/web-server/servlet/bindings-test.rkt

Jay

2011/3/4 John Clements cleme...@brinckerhoff.org:
 I'm doing a web-server/insta example in class, and one of my students (Arlo 
 White, cc:'ed) pointed out that  the existing framework for extracting 
 bindings seems to be missing a bunch of useful functions. In particular, he 
 volunteered to implement a few of the functions from the Spring framework, 
 most notably a function that accepts a request and a name and returns the 
 string associated with that name in the request's bindings.  Like hash-ref, 
 it would allow you to specify your own failure behavior.

 I've run into this myself, and it's always a pain to operate on the request 
 structures.  Would you be open to adding a few functions like this to the 
 web-server (if we provide them, along with docs and tests)? Looking at the 
 documentation, it appears that there's some cleanup that just never made it 
 to the top of someone's list.

 John





-- 
Jay McCarthy j...@cs.byu.edu
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

The glory of God is Intelligence - DC 93

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev