Sha256: 155524c44615d4d6fa41e32b35cd77bcde0021a01e2120216bbdf009cdf55315

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

module Crystal
  module HTTPAdapter
    class << self    
      inject :conveyors => :conveyors,
        :config => :config
      
      def call env, workspace = {}, &block
        # result, opt = nil, opt.to_openobject
        workspace = conveyors.web.call(
          {:env => env, :response => Crystal::Response.new}.merge(workspace.symbolize_keys),
          &block
        )
        
        workspace.response.must_be.defined
        workspace.response.content_type ||= Mime.send(config.default_format)
        result = workspace.response.to_a
        
        result
      end
      # synchronize_method :call
      
      def mock_call env = {}, workspace = {}, &block
        env['PATH_INFO'] ||= '/'
        env['rack.input'] ||= StringIO.new
        
        call env, workspace, &block
      end
    end        
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
crystal-0.0.13 lib/crystal/http/http_adapter.rb
crystal-0.0.12 lib/crystal/http/http_adapter.rb
crystal_ext-0.0.11 lib/crystal/http/http_adapter.rb