Sha256: 8ca4b571e189cbd42e9c2a27f6cf67066e2dbd4ce643843784b72bda65c1913a
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
class WebSystem::RequestPanel < Liza::Panel def call env t = Time.now request_klass = find env ret = request_klass.call env _html_beautify env, ret ret rescue => e request_klass = WebSystem::ServerErrorRequest env["LIZA_ERROR"] = e ret = request_klass.call env ensure log "#{ret[0]} with #{ret[2].first.size} bytes in #{t.diff}s" puts ret end # def find env _prepare env segments = env["LIZA_SEGMENTS"].dup request = segments.shift || "root" action = segments.shift || "index" env["LIZA_REQUEST"] = request env["LIZA_ACTION"] = action format = env["LIZA_FORMAT"] log({request:, action:, format:}) env["LIZA_REQUEST_CLASS"] = _find_request_class request end def _find_request_class request Liza.const "#{request}_request" rescue NameError WebSystem::NotFoundRequest end # def _html_beautify env, ret return unless defined? HtmlBeautifier return unless env["LIZA_FORMAT"] == "html" body = ret[2].first body = HtmlBeautifier.beautify body ret[2] = [body] end def _prepare env log "#{env["REQUEST_METHOD"]} #{env["REQUEST_PATH"]}" path = env["REQUEST_PATH"] path, _sep, format = path.lpartition "." format = "html" if format.empty? segments = Array path.split("/")[1..-1] env["LIZA_PATH"] = path env["LIZA_FORMAT"] = format env["LIZA_SEGMENTS"] = segments end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lizarb-1.0.4 | lib/web_system/web/panels/request_panel.rb |