Created
October 1, 2016 13:34
-
-
Save MasayukiFukada/4be90bfd4e0e229f3b0b0e8722af32f4 to your computer and use it in GitHub Desktop.
Webhookを受けて中身を表示するRuby製サーバーのサンプル
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
| 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