Add ping/pong health check

This commit is contained in:
Sebastian Serth
2021-10-09 23:28:31 +02:00
parent 6a255ced5b
commit bb4b4ece92
4 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,22 @@
# frozen_string_literal: true
class PingController < ApplicationController
before_action :postgres_connected!
after_action :verify_authorized, except: %i[index]
def index
render json: {
message: 'Pong',
timenow_in_time_zone____: DateTime.now.in_time_zone.to_i,
timenow_without_timezone: DateTime.now.to_i,
}
end
private
def postgres_connected!
ApplicationRecord.establish_connection
ApplicationRecord.connection
ApplicationRecord.connected?
end
end