Created
March 2, 2020 14:14
-
-
Save zaru/3362f7c575dcab0c0c3b533d12e366dc to your computer and use it in GitHub Desktop.
rack middleware simple demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
class MyApp < Sinatra::Base | |
get '/' do | |
'top page' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path 'middleware', File.dirname(__FILE__) | |
use Middleware | |
require File.expand_path 'app', File.dirname(__FILE__) | |
run MyApp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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