Skip to content

Commit fae0a63

Browse files
authored
Bug fix (#2)
* Update lambda_utils.rb with example, version, typos
1 parent 8d8a93b commit fae0a63

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

example_handler.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def my_handler(event:, context:)
2121
{
2222
"isBase64Encoded": false,
2323
"statusCode" => 201,
24-
"body" => JSON.generate({ "originalEvent" => event, "my_time" => Time.now.utc.iso8601(3) }),
24+
"body" => JSON.generate({ "originalEvent" => event, "my_time" => Time.now.utc.iso8601(3), "message": "hello" }),
2525
"headers" => {
26-
"content-type" => "application/json"
26+
"content-type" => "application/json"
2727
}
2828
}
2929
end
@@ -36,8 +36,13 @@ def my_handler(event:, context:)
3636

3737
## This creates the moesif_middleware instance that wraps your original handler
3838
$moesif_middleware = Moesif::MoesifAwsMiddleware.new(method(:my_handler), {
39-
"application_id" => 'Your Moesif Application Id',
39+
"application_id" => 'Your Application Id',
4040
"debug" => true,
41+
"identify_user" => Proc.new { |event, context, result|
42+
# Add your custom code that returns a string for user id
43+
puts "identify user is called"
44+
'user_id_12345'
45+
}
4146
})
4247

4348
## This wrapped handler is what you set as the new handler in your aws lambda settings

lib/moesif_aws_lambda/lambda_utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_response_info_from_lambda_result(lambda_result)
5858
status = raw_status.to_i
5959
rsp_body = lambda_result["body"]
6060
rsp_headers = lambda_result["headers"]
61-
if lambda_result.includes?("multiValueHeaders")
61+
if lambda_result.include?("multiValueHeaders")
6262
multi_value_headers = (lambda_result["multiValueHeaders"] || {}).transform_values do |value|
6363
value.join("\n")
6464
end

moesif_aws_lambda.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'moesif_aws_lambda'
3-
s.version = '1.0.0'
3+
s.version = '1.0.1'
44
s.summary = 'moesif_aws_lambda'
55
s.description = 'Moesif aws lambda middleware for Ruby to log API calls to Moesif API analytics and monitoring'
66
s.authors = ['Moesif, Inc', 'Xing Wang']

0 commit comments

Comments
 (0)