mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 20:27:30 +02:00
Save REPP log after every request
This commit is contained in:
parent
9b8d74fe30
commit
6d96a09b5c
2 changed files with 12 additions and 3 deletions
|
@ -4,13 +4,22 @@ module Repp
|
|||
rescue_from ActiveRecord::RecordNotFound, with: :not_found_error
|
||||
before_action :authenticate_user
|
||||
before_action :check_ip_restriction
|
||||
|
||||
attr_reader :current_user
|
||||
|
||||
rescue_from ActionController::ParameterMissing do |exception|
|
||||
render json: { code: 2003, message: exception }, status: :bad_request
|
||||
end
|
||||
|
||||
after_action do
|
||||
ApiLog::ReppLog.create(
|
||||
{ request_path: request.path, request_method: request.request_method,
|
||||
request_params: request.params.except('route_info').to_json, uuid: request.try(:uuid),
|
||||
response: @response.to_json, response_code: status, ip: request.ip,
|
||||
api_user_name: current_user.try(:username),
|
||||
api_user_registrar: current_user.try(:registrar).try(:to_s) }
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_success(code: nil, message: nil, data: nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue