lib/faastruby/local/crystal_runtime.cr in faastruby-0.5.9 vs lib/faastruby/local/crystal_runtime.cr in faastruby-0.5.10
- old
+ new
@@ -121,10 +121,14 @@
resp_body = css
end
FaaStRuby::Response.new(body: resp_body, status: status, headers: headers, binary: bin)
end
+def render_nothing(status : Int32 = 200, headers : Hash(String, String) = {} of String => String)
+ FaaStRuby::Response.new(body: nil, status: status, headers: headers, binary: false)
+end
+
def redirect_to(function : String, status : Int32 = 303)
headers = {"Location" => function}
FaaStRuby::Response.new(body: nil, status: status, headers: headers)
end
@@ -158,10 +162,10 @@
puts e.message
error(msg: "Runtime Error. What are you trying to do?", status: 500)
exit 1
end
spawn do
- response = FaaStRuby::Function.run(event: payload.event)
+ response = FaaStRuby::Function.run(event: payload.event) || render_nothing
puts "R,#{Base64.urlsafe_encode(response.payload.to_json)}"
exit 0
end
max_time = ENV["MAX_EXECUTION_TIME"]? ? ENV["MAX_EXECUTION_TIME"].not_nil!.to_f : 60.0
sleep max_time
\ No newline at end of file