Skip to content

Instantly share code, notes, and snippets.

@MasayukiFukada
Created October 1, 2016 13:34
Show Gist options
  • Save MasayukiFukada/4be90bfd4e0e229f3b0b0e8722af32f4 to your computer and use it in GitHub Desktop.
Save MasayukiFukada/4be90bfd4e0e229f3b0b0e8722af32f4 to your computer and use it in GitHub Desktop.
Webhookを受けて中身を表示するRuby製サーバーのサンプル
require 'webrick'
require 'json'
server = WEBrick::HTTPServer.new(Port: ARGV.first)
server.mount_proc '/' do |req, res|
result = JSON.parse(req.body)
action = result["action"]
comment = result["comment"]
username = comment["user"]["login"]
content = comment["body"]
puts action + "しました: " + username + " = " + content
end
trap 'INT' do server.shutdown end
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment