27 lines
474 B
Crystal
27 lines
474 B
Crystal
require "kemal"
|
|
|
|
strategies_dir = ENV.fetch("STRATEGIES_DIR")
|
|
puts strategies_dir
|
|
|
|
post "/:strategy" do |env|
|
|
strategy = env.params.url["strategy"]
|
|
puts strategy
|
|
output = IO::Memory.new
|
|
params = env.params.query.to_h.to_json
|
|
puts params
|
|
hook = env.params.json.to_json
|
|
puts hook
|
|
Process.run(
|
|
"#{strategies_dir}/#{strategy}",
|
|
[
|
|
hook,
|
|
params,
|
|
],
|
|
output: output,
|
|
error: output,
|
|
)
|
|
puts output.to_s
|
|
output.to_s
|
|
end
|
|
|
|
Kemal.run
|