mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
16 lines
419 B
Ruby
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
|