39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/faastruby/server/runner.rb', line 39
def call(event, args)
begin
case @language
when 'ruby'
time, response = call_ruby(event, args)
when 'crystal'
time, response = call_crystal(event, args)
else
puts "[Runner] ERROR: could not determine the language for function #{@function_name}.".red
end
return [time, response] if response.is_a?(FaaStRuby::Response)
body = {
'error' => "Please use the helpers 'render' or 'respond_with' as your function return value."
}
[time, FaaStRuby::Response.new(body: Oj.dump(body), status: 500, headers: {'Content-Type' => 'application/json'})]
rescue Exception => e
STDOUT.puts e.full_message
body = {
'error' => e.message,
'location' => e.backtrace&.first,
}
[0.0, FaaStRuby::Response.new(body: Oj.dump(body), status: 500, headers: {'Content-Type' => 'application/json'})]
end
end
|