Skip to content

Instantly share code, notes, and snippets.

@zaru
Created March 2, 2020 14:14
Show Gist options
  • Save zaru/3362f7c575dcab0c0c3b533d12e366dc to your computer and use it in GitHub Desktop.
Save zaru/3362f7c575dcab0c0c3b533d12e366dc to your computer and use it in GitHub Desktop.
rack middleware simple demo
require 'sinatra/base'
class MyApp < Sinatra::Base
get '/' do
'top page'
end
end
require File.expand_path 'middleware', File.dirname(__FILE__)
use Middleware
require File.expand_path 'app', File.dirname(__FILE__)
run MyApp
class Middleware
def initialize(app)
@app = app
end
def call(env)
@app.call env
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment