Class: BoltRb::Middleware::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt_rb/middleware/base.rb

Overview

Base class for all middleware

Middleware classes should inherit from this and override #call to implement custom behavior. The default implementation simply yields to the next middleware in the chain.

Examples:

Custom middleware

class AuthMiddleware < BoltRb::Middleware::Base
  def call(context)
    if authorized?(context)
      yield if block_given?
    else
      context.respond("Unauthorized")
    end
  end
end

Direct Known Subclasses

Logging

Instance Method Summary collapse

Instance Method Details

#call(context) { ... } ⇒ void

This method returns an undefined value.

Processes the request through this middleware

Override this method in subclasses to add custom behavior. Always call yield to continue the middleware chain.

Parameters:

Yields:

  • Continues to the next middleware in the chain



30
31
32
# File 'lib/bolt_rb/middleware/base.rb', line 30

def call(context)
  yield if block_given?
end