Skip to content

Instantly share code, notes, and snippets.

@udzura
Created October 21, 2011 01:50

Revisions

  1. udzura revised this gist Oct 21, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion config-1.ru
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ require 'rack/lobster'
    use Rack::CommonLogger
    use Rack::Lint
    use Rack::Auth::Basic do |user, passwd|
    user == "u-kondo" && passwd = "XXX"
    user == "u-kondo" && passwd == "XXX"
    end

    run Rack::Lobster.new
  2. udzura created this gist Oct 21, 2011.
    10 changes: 10 additions & 0 deletions config-1.ru
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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
    24 changes: 24 additions & 0 deletions config-2.ru
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # 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]]
    }