lib/litmus_paper/app.rb in litmus_paper-0.8.6 vs lib/litmus_paper/app.rb in litmus_paper-0.8.7

- old
+ new

@@ -20,10 +20,18 @@ post "/up" do _create_status_file(StatusFile.global_up_file) end + delete "/health" do + _delete_status_file(StatusFile.global_health_file) + end + + post "/health" do + _create_status_file(StatusFile.global_health_file) + end + get "/:service/status" do health = LitmusPaper.check_service(params[:service]) if health.nil? _text 404, "NOT FOUND", { "X-Health" => "0" } else @@ -36,12 +44,18 @@ end headers = {"X-Health" => health.value.to_s} body = "Health: #{health.value}\n" if health.forced? + if health.direction == :health + status = "health" + reason = health.forced_reason.split("\n").join(" ") + else + reason = health.forced_reason + end body << "Measured Health: #{health.measured_health}\n" - body << "Forced Reason: #{health.forced_reason}\n" + body << "Forced Reason: #{reason}\n" end body << health.summary if health.forced? headers["X-Health-Forced"] = status @@ -57,10 +71,18 @@ post "/:service/down" do _create_status_file(StatusFile.service_down_file(params[:service])) end + delete "/:service/health" do + _delete_status_file(StatusFile.service_health_file(params[:service])) + end + + post "/:service/health" do + _create_status_file(StatusFile.service_health_file(params[:service])) + end + delete "/:service/up" do _delete_status_file(StatusFile.service_up_file(params[:service])) end post "/:service/up" do @@ -74,10 +96,10 @@ error do _text 500, "Server Error" end def _create_status_file(status_file) - status_file.create(params[:reason]) + status_file.create(params[:reason], params[:health]) _text 201, "File created" end def _delete_status_file(status_file) if status_file.exists?