From 28be7c4fc4f5c2de3c1c85a0b645e7d00dea2ce2 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 22 Jan 2018 16:52:48 +0100 Subject: [PATCH] Add health check endpoint to API controller [SCI-1970] --- app/controllers/api/api_controller.rb | 10 +++++++--- config/routes.rb | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 246cc25f1..856322ed5 100644 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -4,9 +4,9 @@ module Api attr_reader :token attr_reader :current_user - before_action :load_token, except: %i(authenticate status) - before_action :load_iss, except: %i(authenticate status) - before_action :authenticate_request!, except: %i(authenticate status) + before_action :load_token, except: %i(authenticate status health) + before_action :load_iss, except: %i(authenticate status health) + before_action :authenticate_request!, except: %i(authenticate status health) rescue_from StandardError do |e| logger.error e.message @@ -24,6 +24,10 @@ module Api @iss = nil end + def health + render plain: 'RUNNING' + end + def status response = {} response[:message] = I18n.t('api.core.status_ok') diff --git a/config/routes.rb b/config/routes.rb index 8357cb19a..fa7848cf1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -482,6 +482,7 @@ Rails.application.routes.draw do end namespace :api, defaults: { format: 'json' } do + get 'health', to: 'api#health' get 'status', to: 'api#status' post 'auth/token', to: 'api#authenticate' scope '20170715', module: 'v20170715' do