Merge branch 'master' into 13369-update-ubuntu1404-dockerfile
[arvados.git] / services / api / app / controllers / arvados / v1 / healthcheck_controller.rb
index 41f7175f926f56106c42b105b694e5585a2c48d6..6d55506bb5742cf9be7c183186b60f6479ab5226 100644 (file)
@@ -16,22 +16,20 @@ class Arvados::V1::HealthcheckController < ApplicationController
   before_filter :check_auth_header
 
   def check_auth_header
-    mgmt_token = Rails.configuration.management_token
+    mgmt_token = Rails.configuration.ManagementToken
+    auth_header = request.headers['Authorization']
 
     if !mgmt_token
-      send_error("disabled", status: 404)
-    else
-      auth_header = request.headers['Authorization']
-      if !auth_header
-        send_error("authorization required", status: 401)
-      elsif auth_header != 'Bearer '+mgmt_token
-        send_error("authorization error", status: 403)
-      end
+      send_json ({"errors" => "disabled"}), status: 404
+    elsif !auth_header
+      send_json ({"errors" => "authorization required"}), status: 401
+    elsif auth_header != 'Bearer '+mgmt_token
+      send_json ({"errors" => "authorization error"}), status: 403
     end
   end
 
   def ping
-    resp = {"health": "OK"}
+    resp = {"health" => "OK"}
     send_json resp
   end
 end