Sha256: edea388992a983ab9ecd5814fd7aac1f5d77705b1f5f157a63416245941a74d5
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 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 OMF::Web::ReadOnlyContentRepositoryException return [403, {"Content-Type" => 'text'}, "Read-only repository"] 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
4 entries across 4 versions & 1 rubygems