lib/logster/middleware/viewer.rb in logster-0.0.12 vs lib/logster/middleware/viewer.rb in logster-0.0.13

- old
+ new

@@ -34,10 +34,12 @@ return @app.call(env) end if resource =~ /\.js$|\.handlebars$|\.css$/ env[PATH_INFO] = resource + # accl redirect is going to be trouble, ensure its bypassed + env['sendfile.type'] = '' @fileserver.call(env) elsif resource.start_with?("/messages.json") serve_messages(Rack::Request.new(env)) elsif resource =~ /\/(un)?protect\/([0-9a-f]+)$/ off = $1 == "un" @@ -59,9 +61,19 @@ return [301, {"Location" => "#{@logs_path}/show/#{key}?protected=true"}, []] else return [500, {}, ["Failed"]] end end + + elsif resource =~ /\/clear$/ + puts env + puts env[REQUEST_METHOD] + if env[REQUEST_METHOD] != "POST" + return [405, {}, ["GET not allowed for /clear"]] + end + Logster.store.clear + return [200, {}, ["Messages cleared"]] + elsif resource =~ /\/show\/([0-9a-f]+)(\.json)?$/ key = $1 json = $2 == ".json" message = Logster.store.get(key)