Skip to content

Commit

Permalink
feat(ruby_middleware): add support of middleware creators
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Mar 27, 2023
1 parent 3818985 commit 06bcc15
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# NOTE:
# Copied from `Ibsciss/ruby-middleware` without any logic modification.
# Version: v0.4.2.
# Just wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# Replaced `require` into `require_relative`.
# - Wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# - Replaced `require` into `require_relative`.
# - Added support of middleware creators.
#
# - /~https://github.com/marian13/ruby-middleware/blob/v0.4.2
# - /~https://github.com/Ibsciss/ruby-middleware/blob/v0.4.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# NOTE:
# Copied from `Ibsciss/ruby-middleware` without any logic modification.
# Version: v0.4.2.
# Just wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# Replaced `require` into `require_relative`.
# - Wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# - Replaced `require` into `require_relative`.
# - Added support of middleware creators.
#
# - /~https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware.rb
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module RubyMiddleware
# NOTE:
# Copied from `Ibsciss/ruby-middleware` without any logic modification.
# Version: v0.4.2.
# Just wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# - Wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
#
# - /~https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware/builder.rb
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module RubyMiddleware
# NOTE:
# Copied from `Ibsciss/ruby-middleware` without any logic modification.
# Version: v0.4.2.
# Just wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# - Wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
#
# - /~https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware/logger.rb
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module RubyMiddleware
# NOTE:
# Copied from `Ibsciss/ruby-middleware` without any logic modification.
# Version: v0.4.2.
# Just wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# - Wrapped in a namespace `ConvenientService::Dependencies::Extractions::RubyMiddleware`.
# - Added support of middleware creators.
#
# - /~https://github.com/marian13/ruby-middleware/blob/v0.4.2/lib/middleware/runner.rb
#
Expand Down Expand Up @@ -66,6 +67,13 @@ def build_call_chain(stack)
# If the klass actually is a class, then instantiate it with
# the app and any other arguments given.
klass.new(next_middleware, *args, &block)
##
# IMPORTANT: Customization compared to the original `Runner` implementation.
#
# NOTE: Added support of middleware creators.
#
elsif klass.respond_to?(:new)
klass.new(next_middleware, *args, &block)
elsif klass.respond_to?(:call)
# Make it a lambda which calls the item then forwards up
# the chain.
Expand Down

0 comments on commit 06bcc15

Please sign in to comment.