Sha256: db9d47799eef244f462a0356dca729da50125e8299a705440108ba145f40f9aa

Contents?: true

Size: 694 Bytes

Versions: 3

Compression:

Stored size: 694 Bytes

Contents

module Crystal
  module Processors    
    class PrepareParams < Processor
      def call
        workspace.env.must_be.defined

        workspace.request = Crystal::Request.new(workspace.env)
        workspace.path = workspace.request.path
        params = workspace.params = Crystal::Params.new(workspace.request.params)

        if params.json?
          json_params = JSON.load params['json']
          json_params.must_be.a Hash
          json_params.keys.each do |k|
            logger.warn "Parameter :#{k} will be overwriden from JSON!" if params.include?(k)
          end
          params.merge! json_params
        end
        
        next_processor.call
      end
    end 
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

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