Created
March 27, 2019 18:09
-
-
Save ozydingo/9a1c8642f5ef9570746ff2bf4772ad96 to your computer and use it in GitHub Desktop.
Rails controller to see your request
This file contains hidden or 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
class InpsectionsController < ApplicationController | |
def index | |
log | |
head :ok | |
end | |
def create | |
log | |
head :ok | |
end | |
private | |
def log | |
Rails.logger.info("===============") | |
Rails.logger.info("Raw post:") | |
Rails.logger.info("---------------") | |
Rails.logger.info(request.raw_post) | |
Rails.logger.info("---------------") | |
Rails.logger.info("Method: #{request.method}") | |
Rails.logger.info("Format: #{request.format}") | |
Rails.logger.info("Content type: #{request.content_type}") | |
Rails.logger.info("Params: #{params}") | |
Rails.logger.info("Request params: #{request.request_parameters}") | |
Rails.logger.info("Query params: #{request.query_parameters}") | |
Rails.logger.info("Body: #{request.body.read rescue request.body}") | |
Rails.logger.info("===============") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment