Class: OMF::Web::Rack::ContentHandler
- Inherits:
-
Common::LObject
- Object
- Common::LObject
- OMF::Web::Rack::ContentHandler
- Defined in:
- lib/omf-web/rack/content_handler.rb
Instance Method Summary collapse
Methods inherited from Common::LObject
Methods included from Common::Loggable
#_logger, #debug, #error, #fatal, #info, init_log, logger, set_environment, #warn
Constructor Details
This class inherits a constructor from OMF::Common::LObject
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/omf-web/rack/content_handler.rb', line 10 def call(env) req = ::Rack::Request.new(env) begin c_id = req.path_info[1 .. -1] c_proxy = OMF::Web::ContentProxy[c_id] unless c_proxy raise MissingArgumentException.new "Can't find content proxy '#{c_id}'" end method = "on_#{req.request_method().downcase}" body, headers = c_proxy.send(method.to_sym, req) rescue MissingArgumentException => mex debug mex return [412, {"Content-Type" => 'text'}, [mex.to_s]] rescue Exception => ex error ex debug ex.to_s + "\n\t" + ex.backtrace.join("\n\t") return [500, {"Content-Type" => 'text'}, [ex.to_s]] end if headers.kind_of? String headers = {"Content-Type" => headers} end [200, headers, [body]] end |