Skip to content

Instantly share code, notes, and snippets.

@rhiroyuki
Created December 8, 2018 11:26
Show Gist options
  • Save rhiroyuki/ca77b48471f436dbf70180836365e50f to your computer and use it in GitHub Desktop.
Save rhiroyuki/ca77b48471f436dbf70180836365e50f to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
#
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', __dir__)
require 'sinatra'
require 'sinatra/contrib'
require 'logger'
set :logger, Logger.new(STDOUT)
route :get, :post, :delete, :put, :patch, '/*/?' do
content_type 'application/json'
logger.info "#{request.request_method} method - params: #{params}"
logger.info "#{request.body.read}"
{
body: request.body.read,
query_string: request.query_string,
headers: headers,
params: params,
request_method: request.request_method
}.to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment