Sha256: 2e2cac3f33f32a34eab1f50d5a5197d0c5500d7446c32e873e7c44298712cf2a
Contents?: true
Size: 834 Bytes
Versions: 10
Compression:
Stored size: 834 Bytes
Contents
# coding: utf-8 # frozen_string_literal: true require 'sinatra/base' require 'multi_json' module Stealth class Server < Sinatra::Base def self.get_or_post(url, &block) get(url, &block) post(url, &block) end get '/' do "Welcome to stealth." end get_or_post '/incoming/:service' do Stealth::Logger.l(topic: "incoming", message: "Received webhook from #{params[:service]}") # JSON params need to be parsed and added to the params if request.env['CONTENT_TYPE'] == 'application/json' json_params = MultiJson.load(request.body.read) params.merge!(json_params) end dispatcher = Stealth::Dispatcher.new( service: params[:service], params: params, headers: request.env ) dispatcher.coordinate end end end
Version data entries
10 entries across 10 versions & 1 rubygems