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