nyx/tests/dynamic_fixtures/ruby/rack_middleware/benign.rb
2026-06-05 10:16:30 -05:00

16 lines
419 B
Ruby

# Phase 15 — Rack middleware, benign.
class NyxRackApp
def initialize(app = nil); @app = app; end
def call(env)
payload = env['nyx.payload'] || ENV['NYX_PAYLOAD'] || ''
unless payload =~ /\A[A-Za-z0-9]{1,32}\z/
[400, { 'Content-Type' => 'text/plain' }, ['invalid']]
else
out = `echo hello`
STDOUT.print(out)
[200, { 'Content-Type' => 'text/plain' }, [out]]
end
end
end