Sha256: e91149b4687f8e93e37b0400193649fc34be57a19c0de4fe92a5511bf156af03
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
module Shogun class Dispatch PATH_KEY = "REQUEST_PATH" METHOD_KEY = "REQUEST_METHOD" NO_MATCH = -> { // } require_relative "dispatch/route" require_relative "dispatch/payload" require_relative "dispatch/lookup" attr_reader :routes private :routes attr_reader :payload private :payload attr_reader :lookup private :lookup attr_reader :route private :route def initialize(logger:) @routes = {} @logger = logger yield(self) end def call(state) @state = state lookup = Lookup.new(routes: routes, verb: state[METHOD_KEY], path: state[PATH_KEY]) payload = Payload.new(state: state, lookup: lookup) route = lookup.to_route control = route.control.new(payload: payload) control.to_a end def push(route:) routes[route.as_key] = route end private def stack @stack end private def state @state end private def headers @headers end private def status @status end private def body @body end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
shogun-3.0.0 | lib/shogun/dispatch.rb |
shogun-2.1.1 | lib/shogun/dispatch.rb |
shogun-2.1.0 | lib/shogun/dispatch.rb |
shogun-2.0.0 | lib/shogun/dispatch.rb |
shogun-1.0.0 | lib/shogun/dispatch.rb |