Sha256: 70aa9b1396b6773a7338bde27f84a34c195dc17583f77f4ce8cc74cd5edd3c97
Contents?: true
Size: 939 Bytes
Versions: 2
Compression:
Stored size: 939 Bytes
Contents
require 'sinatra/base' require 'json' module Pushpop class Web def app Sinatra::Application end def routes @routes ||= [] end def add_route(url, job) if url[0] != '/' url = "/#{url}" end raise "Route #{url} is already set up as a webhook" if routes.include?(url) runner = lambda do response = self.instance_eval(&job.webhook_proc) if response job.run(response, {'webhook' => response}) { status: 'success', job: job.name }.to_json else { status: 'failed', job: job.name, message: 'webhook step did not pass' }.to_json end end Sinatra::Application.get url, &runner Sinatra::Application.post url, &runner Sinatra::Application.put url, &runner routes.push(url) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pushpop-0.3.3 | lib/pushpop/web.rb |
pushpop-0.3.2 | lib/pushpop/web.rb |