helpers/request.rb
# Formats a payload for sending via Slack
#
# @return [Hash] Our Payload in Slack "attachment" format.
Formats a payload for sending via Slack
Formats a payload for sending via Slack
def format_for_slack
            slack_summary = "New request to #{request_uri}"
            slack_attachment_fields = [
                {
                    'title': 'Request URI',
                    'value': request_uri,
                    'short': false,
                },
                {
                    'title': 'IP Address',
                    'value': ip,
                    'short': false,
                },
                {
                    'title': 'Headers',
                    'value': headers.map{ |k,v| "#{k}: #{v}"}.join("\n"),
                    'short': false,
                },
                {
                    'title': 'Parameters',
                    'value': params.map{ |k,v| "#{k}: #{v}"}.join("\n"),
                    'short': false,
                },
            ]
            unless params['target'].nil?
                slack_summary = "#{slack_summary} from #{params['target']}"
                slack_attachment_fields << {
                    'title': 'Target',
                    'value': params['target'],
                    'short': false,
                }
            end
            slack_summary += "!"
            return Slack::format_attachment(slack_summary, slack_attachment_fields)
        end
def format_for_slack slack_summary = "New request to #{request_uri}" slack_attachment_fields = [ { 'title' : 'Request URI' , 'value' : request_uri , 'short' : false , } , { 'title' : 'IP Address' , 'value' : ip , 'short' : false , } , { 'title' : 'Headers' , 'value' : headers . map { | k , v | "#{k}: #{v}" } . join ( "\n" ) , 'short' : false , } , { 'title' : 'Parameters' , 'value' : params . map { | k , v | "#{k}: #{v}" } . join ( "\n" ) , 'short' : false , } , ] unless params [ 'target' ] . nil? slack_summary = "#{slack_summary} from #{params['target']}" slack_attachment_fields << { 'title' : 'Target' , 'value' : params [ 'target' ] , 'short' : false , } end slack_summary += "!" return Slack :: format_attachment ( slack_summary , slack_attachment_fields ) end
Formats a payload for sending via Slack
Formats a payload for sending via Slack
# Send the request to Slack. # Add target information if we have it! # Gotta keep it light & breezy, Peralta.
Our Payload in Slack "attachment" format.
Our Payload in Slack " attachment " format .
Hash