Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@udzura
Created October 21, 2011 01:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save udzura/1302918 to your computer and use it in GitHub Desktop.
Save udzura/1302918 to your computer and use it in GitHub Desktop.
Sinppets for copy-paste used in Start Padrino
require 'rack'
require 'rack/lobster'
use Rack::CommonLogger
use Rack::Lint
use Rack::Auth::Basic do |user, passwd|
user == "u-kondo" && passwd == "XXX"
end
run Rack::Lobster.new
# coding: utf-8
require 'rack'
require 'open-uri'
class Harukazefier
def initialize(app)
@app = app
end
def call(env)
orig_res = @app.call(env)
res = Rack::Response.new orig_res[2], orig_res[0], orig_res[1]
res.body = res.body.map{|txt| txt.gsub(/。/, "(ω)") }
res["Content-Length"] = res.body.first.bytesize.to_s
res.finish
end
end
blog = "http://blog.udzura.jp/2011/10/04/sinatra-1-3-0-and-padrino-0-10-3-released-1/"
use Rack::Lint
use Harukazefier
run lambda {|env|
[200, {"Content-Type" => "text/html"}, [open(blog).read]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment