Sha256: 01d5fe2f94dd7ce4efcf13b87c65cbe3e7b54b32ed8c300fa8f5ea507510ffb8

Contents?: true

Size: 827 Bytes

Versions: 6

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true

require "rack"
require "hanami/controller"
require_relative "router"

module Snowpack
  module Web
    class Application
      def initialize(application, &routes)
        resolver = application.config.web.routing.endpoint_resolver.new(
          application: application,
          namespace: application.config.web.routing.action_key_namespace,
        )

        router = Router.new(
          application: application,
          endpoint_resolver: resolver,
          &routes
        )

        @app = Rack::Builder.new do
          use application[:rack_monitor]

          router.middlewares.each do |(*middleware, block)|
            use(*middleware, &block)
          end

          run router
        end
      end

      def call(env)
        @app.call(env)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
snowpack-1.0.0.alpha7 lib/snowpack/web/application.rb
snowpack-1.0.0.alpha6 lib/snowpack/web/application.rb
snowpack-1.0.0.alpha5 lib/snowpack/web/application.rb
snowpack-1.0.0.alpha4 lib/snowpack/web/application.rb
snowpack-1.0.0.alpha3 lib/snowpack/web/application.rb
snowpack-1.0.0.alpha2 lib/snowpack/web/application.rb