Sha256: a89cd56391cb4ca7714f21298ce97d44e222ef1f04f67df13f49520b3d40e023

Contents?: true

Size: 792 Bytes

Versions: 9

Compression:

Stored size: 792 Bytes

Contents

require 'rubygems'
require 'rack'
require 'webrick'

class SampleApp

  def self.start(host, port)
    Rack::Handler::WEBrick.run new,
                               :Host => host,
                               :Port => port,
                               :Logger => ::WEBrick::Log.new(RUBY_PLATFORM =~ /mswin|mingw/ ? 'NUL:' : '/dev/null'),
                               :AccessLog => [nil, nil]
  end

  def initialize
    @public = Rack::File.new(File.expand_path("../public", __FILE__))
  end

  def call(env)
    req = Rack::Request.new(env)

    case req.path
    when "/"
      [200, {}, ["Sample Application"]]
    when "/compute"
      sleep 5
      resp = eval(req.params['calculator-expression']).to_s
      [200, {}, [resp]]
    else
      @public.call(env)
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
druid-ts-1.2.6 features/sample-app/sample_app.rb
druid-ts-1.2.5 features/sample-app/sample_app.rb
druid-ts-1.2.4 features/sample-app/sample_app.rb
druid-ts-1.2.3 features/sample-app/sample_app.rb
druid-ts-1.2.2 features/sample-app/sample_app.rb
druid-ts-1.2.1 features/sample-app/sample_app.rb
druid-ts-1.2.0 features/sample-app/sample_app.rb
druid-ts-1.1.8 features/sample-app/sample_app.rb
druid-ts-1.1.7 features/sample-app/sample_app.rb