Sha256: 93c70039c6ded08bd7e0ec74b4dd861ee6a399ea307efa872b514a548082e4a0

Contents?: true

Size: 475 Bytes

Versions: 2

Compression:

Stored size: 475 Bytes

Contents

module Rollerskates
  class Application
    attr_reader :routes

    def initialize
      @routes = Routing::Router.new
    end

    def call(env)
      @request = Rack::Request.new(env)
      route = mapper.map_to_route(@request)
      if route
        response = route.dispatch
        return response.finish(route.method_name)
      end
      [404, {}, ["Route not found"]]
    end

    def mapper
      @mapper ||= Routing::Mapper.new(routes.endpoints)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rollerskates-0.1.1 lib/rollerskates/application.rb
rollerskates-0.1.0 lib/rollerskates/application.rb