Sha256: c6b0fd4864fac51c8475a4c8a46ee505b88de87d22854999a9f10266308b2985
Contents?: true
Size: 629 Bytes
Versions: 1
Compression:
Stored size: 629 Bytes
Contents
# frozen_string_literal: true module CottonTail module Middleware # Router Middleware class Router def initialize(app) @app = app end def call(request) message = parse(request) request.shift request.unshift message.app.env @app.call handler(message.app, message.routing_key).call(request) end private def handler(app, route) handlers(app).fetch(route) { raise UndefinedRouteError } end def parse(msg) Message.new(*msg) end def handlers(app) app.routes.handlers end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cotton-tail-0.3.0 | lib/cotton_tail/middleware/router.rb |