lib/merb/merb_controller.rb in merb-0.0.2 vs lib/merb/merb_controller.rb in merb-0.0.3

- old
+ new

@@ -1,9 +1,16 @@ module Merb + # controller class for the merb pocket-framework. All of your + # controllers will inherit from Merb::Controller. This superclass + # takes care of parsing the incoming headers and body into params + # and cookies and headers. If the request is a file upload it will + # stream it into a tempfile and pass in the filename and tempfile object + # to your controller via params. It also parses the ?query=string and + # puts that into params as well. class Controller - attr_accessor :status, :headers + attr_accessor :status # Stolen from Camping without a twinge of remorse ;) def initialize(req, env, method=(env['REQUEST_METHOD']||"GET")) #:nodoc: env = MerbHash[env.to_hash] puts env.inspect if $DEBUG puts req.inspect if $DEBUG @@ -47,9 +54,21 @@ elsif @method == "post" qs.merge!(query_parse(@in.read)) end @cookies, @params = @k.dup, qs.dup end + + def params + @params + end + + def cookies + @cookies + end + + def headers + @headers + end def query_parse(qs, d = '&;') m = proc {|_,o,n|o.update(n,&m)rescue([*o]<<n)} (qs||'').split(/[#{d}] */n).inject(MerbHash[]) { |h,p| k, v=unescape(p).split('=',2) \ No newline at end of file