Created
January 6, 2024 08:38
-
-
Save kinsomicrote/dcf8cb1fa654b16555302b451fd2638e to your computer and use it in GitHub Desktop.
rails http header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_action :log_request | |
def log_request | |
Rails.logger.info "Request: #{request.method} #{request.fullpath}" | |
http_envs = {}.tap do |envs| | |
request.headers.each do |key, value| | |
envs[key] = value if key.downcase.starts_with?('http') | |
end | |
end | |
logger.info <<-LOG.squish | |
Received #{request.method.inspect} | |
to #{request.url.inspect} | |
from #{request.remote_ip.inspect}. | |
Processing | |
with headers #{http_envs.inspect} | |
and params #{params.inspect}" | |
LOG | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment