Sha256: f170131c4f823be988eff2d6cea8be91736e0e1008fc0904e6be7e37e97bb34a
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
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 <html> <head> <title>Stealth</title> </head> <body> <center> <a href='https://hellostealth.org'> <img src='http://assets.blackops.nyc/stealth/logo.svg' height='120' alt='Stealth Logo' aria-label='hellostealth.org' /> </a> </center> </body> </html> WELCOME end get_or_post '/incoming/:service' do if Stealth.env == 'development' Stealth::Logger.l(topic: "ARGF", message: "RELOADING") ActiveSupport::Dependencies.clear end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stealth-1.0.0.pre1 | lib/stealth/server.rb |