Skip to content

Instantly share code, notes, and snippets.

@jhnbwrs
jhnbwrs / http_proxy.rb
Last active August 29, 2015 14:23
A simple HTTP Proxy
# You are free to copy and use this code in any way you see fit
# with absolutely no requirements, but no warranty is provided.
require 'rubygems'
require 'sinatra/base'
require 'net/http'
require 'logger'
module PassThroughProxy
class Api < Sinatra::Base
attr_accessor :logger
@jhnbwrs
jhnbwrs / jsonfileserv.rb
Last active August 29, 2015 14:23
Sinatra server JSON file get requests mirroring directory structure
require 'sinatra/base'
require 'json'
require 'pathname'
FIXTURESDIR="fixtures"
class JSONFileServer < Sinatra::Base
#TODO: When request is not JSON return 406
# when request.accept.include?("application/json") #JSON requested