Sha256: 93d3e5759cfd7fe7e055570dbe1a3ac55ade9dc05c7ec9a0dee63367952eae18

Contents?: true

Size: 591 Bytes

Versions: 16

Compression:

Stored size: 591 Bytes

Contents

require 'sinatra'
require 'json'

get '/' do
  result.to_json
end

get '/path/to/resource' do
  result.to_json
end

post '/' do
  result.to_json
end

def result
  {
    'app' => 'sinatra',
    'method' => request.request_method,
    'path' => request.path_info,
    'params' => params,
    'headers' => RequestWrapper.new(request).headers,
  }
end

class RequestWrapper
  def initialize(request)
    @request = request
  end

  def headers
    headers = @request.env.select do |k, v|
      k.start_with?('HTTP_')
    end.map do |k, v|
      [k[5..-1], v]
    end
    Hash[headers]
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
infrataster-0.2.4 spec/integration/vm/app/app.rb
infrataster-0.2.3 spec/integration/vm/app/app.rb
infrataster-0.2.2 spec/integration/vm/app/app.rb
infrataster-0.2.1 spec/integration/vm/app/app.rb
infrataster-0.2.0 spec/integration/vm/app/app.rb
infrataster-0.2.0.beta1 spec/integration/vm/app/app.rb
infrataster-0.1.13 spec/integration/vm/app/app.rb
infrataster-0.1.12 spec/integration/vm/app/app.rb
infrataster-0.1.11 spec/integration/vm/app/app.rb
infrataster-0.1.10 spec/integration/vm/app/app.rb
infrataster-0.1.9 spec/integration/vm/app/app.rb
infrataster-0.1.8 spec/integration/vm/app/app.rb
infrataster-0.1.7 spec/integration/vm/app/app.rb
infrataster-0.1.6 spec/integration/vm/app/app.rb
infrataster-0.1.5 spec/integration/vm/app/app.rb
infrataster-0.1.4 spec/integration/vm/app/app.rb