[macruby-changes] [4030] ControlTower/branches/gcd-ify
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 6 02:31:02 PDT 2010
Revision: 4030
http://trac.macosforge.org/projects/ruby/changeset/4030
Author: joshua.ballanco at apple.com
Date: 2010-05-06 02:30:59 -0700 (Thu, 06 May 2010)
Log Message:
-----------
Added some samples
Modified Paths:
--------------
ControlTower/branches/gcd-ify/HACKING.rdoc
Added Paths:
-----------
ControlTower/branches/gcd-ify/sample/
ControlTower/branches/gcd-ify/sample/file_upload.ru
ControlTower/branches/gcd-ify/sample/simple_hello.ru
Modified: ControlTower/branches/gcd-ify/HACKING.rdoc
===================================================================
--- ControlTower/branches/gcd-ify/HACKING.rdoc 2010-05-06 08:26:03 UTC (rev 4029)
+++ ControlTower/branches/gcd-ify/HACKING.rdoc 2010-05-06 09:30:59 UTC (rev 4030)
@@ -10,9 +10,9 @@
== CAUTION! AVERTISSEMENT! VOORZICHTIG! 注意!
-DO NOT EDIT http11_parser.c! THIS FILE IS MACHINE GENERATED CODE.
+DO NOT EDIT http11_parser.c! THIS FILE CONTAINS MACHINE GENERATED CODE.
NE PAS http11_parser.c EDIT! Ce fichier est code machine généré.
-EDIT http11_parser.c NIET! Dit bestand wordt MACHINE gegenereerde code.
+WIJZIG http11_parser.c NIET! Dit bestand bevat MACHINE gegenereerde code.
編集しないのhttp11_parser.c!このファイルを機械生成されたコードです。
If you really must, you can recreate http11_parser.c from http11_parser.rl using
@@ -20,17 +20,47 @@
once, but editing it is not likely to ever be a good idea.
-=== Debugging
+== Sample Code
-==== Environment variables
+There are two samples that you can run to explore ControlTower's behavior on GET
+and POST requests located in the 'sample' directory. To use these samples, first
+build and install the Control Tower gem:
+> rake gem
+> sudo macgem install pkg/control_tower-0.1-universal-darwin-10.gem
+
+Then, to try a GET request, start the 'simple_hello.ru' rack-up config like so:
+
+> control_tower -R sample/simple_hello.ru
+
+and test it with a utility such as curl like so:
+
+> curl http://localhost:8080/
+
+This should reply with a very traditional string and a read-out of the rack
+environment generated by your request. To try a POST request, start the
+'file_upload.ru' config as above, then use curl (or similar tool) to send a post
+with some file content like so:
+
+> curl -F "test=@README.rdoc" http://localhost:8080/
+
+This command tells curl to send the file as a form parameter, and the reply
+should contain the content of the rack 'params' variable constructed from this
+parameter.
+
+
+== Debugging
+
+=== Environment variables
+
Currently, there is only one environment variable specifically for debugging
Control Tower:
* CT_DEBUG: This will turn on debug logging until we get a better logger.
-=== Known Issues
+== Known Issues
+
* Error compiling Regular Expression in Rack::Request
Workaround: Modify line 150 in rack/request.rb like so
- form_vars.sub!(/\0\z/, '')
Added: ControlTower/branches/gcd-ify/sample/file_upload.ru
===================================================================
--- ControlTower/branches/gcd-ify/sample/file_upload.ru (rev 0)
+++ ControlTower/branches/gcd-ify/sample/file_upload.ru 2010-05-06 09:30:59 UTC (rev 4030)
@@ -0,0 +1,17 @@
+require 'rack'
+
+class Uploader
+ def call(env)
+ params = Rack::Request.new(env).params
+ response = params.map do |k,v|
+ if k == 'file' && v[:tempfile]
+ "#{k} => File Contents: #{v[:tempfile].read}"
+ else
+ "#{k} => #{v.inspect}"
+ end
+ end.join("\n")
+ [200, { 'Content-Type' => 'text/plain' }, response]
+ end
+end
+
+run Uploader.new
Added: ControlTower/branches/gcd-ify/sample/simple_hello.ru
===================================================================
--- ControlTower/branches/gcd-ify/sample/simple_hello.ru (rev 0)
+++ ControlTower/branches/gcd-ify/sample/simple_hello.ru 2010-05-06 09:30:59 UTC (rev 4030)
@@ -0,0 +1,7 @@
+class Hello
+ def call(env)
+ [200, { 'Content-Type' => 'text/plain' }, "Hello, world! Your environment is #{env}"]
+ end
+end
+
+run Hello.new
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100506/7045c43e/attachment.html>
More information about the macruby-changes
mailing list