Sha256: 9f656f0a29d603bae58a498ce70fc286d456cadf922e4e832df75df5a6fea89b
Contents?: true
Size: 909 Bytes
Versions: 2
Compression:
Stored size: 909 Bytes
Contents
require 'orange/packet' # Orange Middleware is a bit more complex than Rack middleware. # Initializing it requires both a link to the downstream app and # the core, and calling the app often requires an Orange::Packet # # Orange::Middleware::Base takes care of these basic tasks. # Subclasses override the init method for extra initialization # and the packet_call for a call with a packet, rather than # a basic call module Orange::Middleware class Base def initialize(app, core, *args) @app = app @core = core init(*args) end def init(*args) end def call(env) packet = Orange::Packet.new(@core, env) packet_call(packet) end def packet_call(packet) pass packet end def pass(packet) @app.call(packet.env) end def orange; @core; end def inspect self.to_s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
orange-0.0.3 | lib/orange/middleware/base.rb |
orange-0.0.2 | lib/orange/middleware/base.rb |