Sha256: a2e2352ac9e8c020372b05a48f5c3b7de8566042005763ac3820a0e383235646
Contents?: true
Size: 755 Bytes
Versions: 4
Compression:
Stored size: 755 Bytes
Contents
require 'sinatra/base' class HttpTestServer < Sinatra::Base get "/method" do text 200, "GET" end post "/method" do text 200, "POST" end get "/status/:response_status" do if params[:response_status] =~ /\A\d+\z/ status = params[:response_status] message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || "Unknown" text status.to_i, "#{status} #{message}" else text 500, "Invalid Status" end end get "/sleep/:seconds" do sleep params[:seconds].to_f $stderr.puts "sleeping #{params[:seconds]}" text 200, "Woke up after #{params.inspect} seconds" end def text(response_code, body, headers ={}) [response_code, { "Content-Type" => "text/plain" }.merge(headers), body] end end
Version data entries
4 entries across 4 versions & 1 rubygems