26 lines
463 B
Crystal
26 lines
463 B
Crystal
require "kemal"
|
|
|
|
strategies_dir = ENV.fetch("STRATEGIES_DIR")
|
|
puts strategies_dir
|
|
|
|
post "/:strategy" do |env|
|
|
strategy = env.params.url["strategy"]
|
|
params = env.params.query.to_h.to_json
|
|
hook = env.params.json.to_json
|
|
|
|
puts strategy
|
|
puts params
|
|
puts hook
|
|
|
|
Process.run(
|
|
"#{strategies_dir}/#{strategy}",
|
|
args: [hook, params],
|
|
) do |proc|
|
|
loop do
|
|
puts proc.output.gets
|
|
break if proc.terminated?
|
|
end
|
|
end
|
|
end
|
|
|
|
Kemal.run
|