require File.dirname(__FILE__)+'/mixins/controller_mixin' require File.dirname(__FILE__)+'/mixins/render_mixin' module Merb # 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 include ::ControllerMixin include ::RenderMixin if Merb::Server.config[:session] require File.dirname(__FILE__)+"/session/merb_session" include ::Merb::SessionMixin puts "session mixed in" end attr_accessor :status # parses the http request into params, headers and cookies # that you can use in your controller classes. Also handles # file uploads by writing a tempfile and passing a reference # in params. def initialize(req, env, args, method=(env['REQUEST_METHOD']||"GET")) #:nodoc: env = MerbHash[env.to_hash] @layout = 'application' @status, @method, @env, @headers, @root = 200, method.downcase, env, {'Content-Type'=>'text/html'}, env['SCRIPT_NAME'].sub(/\/$/,'') @k = query_parse(env['HTTP_COOKIE'], ';,') qs = query_parse(env['QUERY_STRING']) @in = req if %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)|n.match(env['CONTENT_TYPE']) b = /(?:\r?\n|\A)#{Regexp::quote("--#$1")}(?:--)?\r$/ until @in.eof? fh=MerbHash[] for l in @in case l when "\r\n" : break when /^Content-Disposition: form-data;/ fh.update MerbHash[*$'.scan(/(?:\s(\w+)="([^"]+)")/).flatten] when /^Content-Type: (.+?)(\r$|\Z)/m puts "=> fh[type] = #$1" fh[:type] = $1 end end fn=fh[:name] o=if fh[:filename] o=fh[:tempfile]=Tempfile.new(:Merb) o.binmode else fh="" end while l=@in.read(16384) if l=~b o<<$`.chomp @in.seek(-$'.size,IO::SEEK_CUR) break end o<

No Matching Route

" end end