Sha256: 2ae8a99de95a601c64fe3752a0ab917f2ff9d473e1215b416e69bed579a5b7fd
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
require 'omf_base/lobject' require 'omf-web/rack/rack_exceptions' require 'omf-web/content/content_proxy' module OMF::Web::Rack class ContentHandler < OMF::Base::LObject 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 end # ContentHandler end # OMF:Web
Version data entries
6 entries across 6 versions & 1 rubygems