NRuby
20 строк · 338.0 Байт
1require 'rack'
2
3class MyMiddleware
4def initialize(app)
5@app = app
6end
7
8def call(env)
9unless env['PATH_INFO'] == '/'
10return [404, { 'Content-Type' => 'text/plain' }, ['Not Found']]
11end
12@app.call(env)
13end
14end
15
16use MyMiddleware
17
18run ->(env) do
19[200, { 'Content-Type' => 'text/plain' }, ['Hello, world!']]
20end
21