Sha256: b231308984953d56eea7fab1d9d0256f83585fd63f5d862ae7f9a02d61d3332f

Contents?: true

Size: 885 Bytes

Versions: 24

Compression:

Stored size: 885 Bytes

Contents

rad.http

class HttpWriter < Rad::Conveyors::Processor      
  def call
    response = workspace.response.must_be.defined
    
    begin
      next_processor.call

      response.body = workspace.content if response.body.blank? and workspace.content?
      response.content_type ||= Mime[(workspace.params.format if workspace.params?) || rad.http.default_format]          
    rescue StandardError => e       
      raise e if rad.test?
      
      response.clear          
      if workspace.params.format? and workspace.params.format == 'json'
        response.body = {error: (rad.production? ? "Internal error!" : e.message)}.to_json
        response.content_type = Mime.json
      else
        response.body = (rad.production? ? "Internal error!" : e.message)
        response.content_type = Mime.text
      end
      
      logger.error e
      logger.info "\n"
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rad_core-0.2.6 lib/rad/http/processors/http_writer.rb
rad_core-0.2.5 lib/rad/http/processors/http_writer.rb
rad_core-0.2.4 lib/rad/http/processors/http_writer.rb
rad_core-0.2.3 lib/rad/http/processors/http_writer.rb
rad_core-0.2.2 lib/rad/http/processors/http_writer.rb
rad_core-0.2.1 lib/rad/http/processors/http_writer.rb
rad_core-0.2.0 lib/rad/http/processors/http_writer.rb
rad_core-0.0.30 lib/rad/http/processors/http_writer.rb
rad_core-0.0.29 lib/rad/http/processors/http_writer.rb
rad_core-0.0.28 lib/rad/http/processors/http_writer.rb
rad_core-0.0.27 lib/rad/http/processors/http_writer.rb
rad_core-0.0.26 lib/rad/http/processors/http_writer.rb
rad_core-0.0.25 lib/rad/http/processors/http_writer.rb
rad_core-0.0.24 lib/rad/http/processors/http_writer.rb
rad_core-0.0.23 lib/rad/http/processors/http_writer.rb
rad_core-0.0.22 lib/rad/http/processors/http_writer.rb
rad_core-0.0.21 lib/rad/http/processors/http_writer.rb
rad_core-0.0.20 lib/rad/http/processors/http_writer.rb
rad_core-0.0.19 lib/rad/http/processors/http_writer.rb
rad_core-0.0.18 lib/rad/http/processors/http_writer.rb