Sha256: 09e78ff69c1b01701cc070b7f85076691ec350e80038944c1b54cdeb0964df4b

Contents?: true

Size: 750 Bytes

Versions: 9

Compression:

Stored size: 750 Bytes

Contents

module VersionCake
  module Rack
    class Middleware

      def initialize(app, config=VersionCake.config)
        @app = app
        @version_service = VersionCake::VersionContextService.new(config)
        @response_service = VersionCake::VersionedResponseService.new(config)
        @config = config
      end

      def call(env)
        request = ::Rack::Request.new env
        if context = @version_service.create_context_from_request(request)
          env['versioncake.context'] = context

          status, headers, response = @app.call(env)

          @response_service.inject_version(context, status, headers, response)

          [status, headers, response]
        else
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
versioncake-4.1.1 lib/versioncake/rack/middleware.rb
versioncake-4.1.0 lib/versioncake/rack/middleware.rb
versioncake-4.0.2 lib/versioncake/rack/middleware.rb
versioncake-4.0.1 lib/versioncake/rack/middleware.rb
versioncake-4.0.0 lib/versioncake/rack/middleware.rb
versioncake-3.4.0 lib/versioncake/rack/middleware.rb
versioncake-3.3.0 lib/versioncake/rack/middleware.rb
versioncake-3.2.0 lib/versioncake/rack/middleware.rb
versioncake-3.1.0 lib/versioncake/rack/middleware.rb