Sha256: 4d58ca6cf47ef68cc70d8897a33f84f077e71cbcc7b9486719236d32dbeacc3c
Contents?: true
Size: 754 Bytes
Versions: 1
Compression:
Stored size: 754 Bytes
Contents
require 'json' require_relative 'command_handler' require_relative 'serializer' class App HTML = <<~HEREDOC <!DOCTYPE html> <html> <head> <script src='build/app.js'></script> </head> <body> <div id="root"></div> </body> </html> HEREDOC def call (env) req = Rack::Request.new(env) case req.path_info when '/rock/command' [200, { 'Content-Type' => 'application/json; charset=utf-8' }, [run_command(req)]] else [200, { 'Content-Type' => 'text/html; charset=utf-8' }, [HTML]] end end def run_command(req) json = JSON.parse(req.body.read) result = CommandHandler.new.handle(json['type'].to_sym, json['payload']) Serializer.serialize(result) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
beryl-0.1.0 | lib/app.rb |