forked from aws/aws-lambda-ruby-runtime-interface-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.rb
57 lines (47 loc) · 981 Bytes
/
core.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
require 'stringio'
def ping(event:, context:)
resp = {}
if event.nil?
resp[:event_nil] = true
else
resp[:msg] = "pong[#{event["msg"]}]"
end
puts "Hello, loggers!"
resp
end
def str_ping(event:, context:)
{ msg: "pong[#{event}]" }
end
def broken(_)
raise ArgumentError.new("My error message.")
end
def string(event:, context:)
"Message: '#{event["msg"]}'"
end
def curl(event:,context:)
resp = Net::HTTP.get(URI(event["url"]))
if resp.size > 0
{ success: true }
else
raise "Empty response!"
end
end
def io(_)
StringIO.new("This is IO!")
end
def execution_env(_)
{ "AWS_EXECUTION_ENV" => ENV["AWS_EXECUTION_ENV"] }
end
class HandlerClass
def self.ping(event:,context:)
"Module Message: '#{event["msg"]}'"
end
end
module DeepModule
class Handler
def self.ping(event:,context:)
"Deep Module Message: '#{event["msg"]}'"
end
end
end