ewgi_api:request(Ctx) yields:
{ewgi_request,undefined,39,"application/x-www-form-urlencoded",
{ewgi_spec,#Fun<ewgi_mochiweb.4.90721746>,#Fun<ewgi_mochiweb.
5.71601957>,
"http",
{1,0},
{3,
{"beep.session_id","74bd4ae7a0fca49191a5569a5a010ba86a1306da",
{"beep.controller","login_controller",
{"beep.action","create",nil,nil},
nil},
nil}}},
"EWGI/1.0",
{ewgi_http_headers,
"application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5",
"__utma
=111872281.2422505602724073500.1246365803.1246451219.1246907734.3;
__utmz=111872281.1246365803.1.1.utmcsr=(direct)|utmccn=(direct)|
utmcmd=(none);
_beepbeep_session_id_=74bd4ae7a0fca49191a5569a5a010ba86a1306da",
"localhost:8000",undefined,
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us)
AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19",
undefined,
{6,
{"accept-encoding",
[{'Accept-Encoding',"gzip, deflate"}],
nil,
{"accept-language",
[{'Accept-Language',"en-us"}],
nil,
{"cache-control",
[{'Cache-Control',"max-age=0"}],
nil,
{"connection",
[{'Connection',"keep-alive"}],
nil,
{"origin",
[{"Origin","http://localhost:8000"}],
nil,
{"referer",
[{'Referer',"http://localhost:8000/login/new"}],
nil,nil}}}}}}}},
"/login/create",undefined,
[],"127.0.0.1",undefined,undefined,undefined,
undefined,'POST',[],"localhost",undefined,"HTTP/1.1","MochiWeb"}
No values are passed though.
Oh, while we are at it :) How would you handle file uploads with ewgi?
I think it is best for this sort of request parsing to be handled by a
middleware component. Something like this should do the trick:
http://github.com/skarab/ewgi_examples/commit/f8a5451992d2b72d73749bf2432bd05afea4688f
That way, the web framework can choose where to store the parsed form
variables (in the example above, I took Fillipo's cue and store them
in REMOTE_USER_DATA, although a better place may actually be a
framework-specific variable in the extra data tree).
Unfortunately, I think it's important to maintain the flexibility at
this level of the abstraction. ewgi was originally meant just as a
specification, leaving things like parsing POST requests to the web
framework using the spec.
> I beliebe we should create a simple/standardized middleware to handle
> simple forms and file uploads. And let developers build on that.
I agree. I can start adding pieces of middleware like this to the
smak library if you are interested? What other pieces of
functionality does beepbeep need which could be handled by
standardised middleware? We talked about file uploads (content type
multipart/form-data, from RFC 2388), so that would probably be useful
as well.