Sha256: 9ffe34bc0326c203dd80a96a45c50788c8fdd3bec1412d86b878a12ec00f7fcc

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

class MeddlingMessageMiddleware
  # Message middlewares have the following KWargs available to them

  # parsed_data => Raw JSON of schema
  # schema => Schematized objected of data. schema.payload.event has much of the data you will want to mess with
  # socket_event => The socket_event object that was given -- Unlikely you need to play with this
  # listener => { handler:, on_success:, on_failure: } if the listener exists for the schema type; will be nil otherwise
  # type => will be one of :message, :ope, :close
  # websocket => The websocket client attached to Slack
  def call(parsed_data:, schema:, socket_event:, listener:, type:, websocket:)
    ###
    # Code to execute BEFORE the listener handler is called
    ###
    puts "I get called BEFORE the Handler gets executed"



    # The middleware chain is broken if yield is not called
    # If provided, the listener handler will not get called either
    # There may be occasions when you want to halt the middleware chain, but
    # for the most part, ensure you always yield
    yield



    ###
    # Code to execute AFTER the listener handler is called
    ###
    puts "I get called AFTER the Handler gets executed"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack_bot-events-0.4.4 examples/middleware/meddling_message_middleware.rb