Skip to content

Commit f592cac

Browse files
authored
feat: adding ruby runtime support and example (#509)
1 parent 36dd0a9 commit f592cac

File tree

7 files changed

+1075
-0
lines changed

7 files changed

+1075
-0
lines changed

examples/ruby/.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# next.js build output
61+
.next
62+
63+
dist/
64+
.serverless
65+
.serverless_plugins

examples/ruby/Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "https://rubygems.org"
2+
3+
gem "httparty"
4+
5+
ruby '~> 3.3'

examples/ruby/app.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# require 'httparty'
2+
require 'json'
3+
4+
def lambda_handler(event:, context:)
5+
# Sample pure Lambda function
6+
7+
# Parameters
8+
# ----------
9+
# event: Hash, required
10+
# API Gateway Lambda Proxy Input Format
11+
# Event doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-input-format
12+
13+
# context: object, required
14+
# Lambda Context runtime methods and attributes
15+
# Context doc: https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html
16+
17+
# Returns
18+
# ------
19+
# API Gateway Lambda Proxy Output Format: dict
20+
# 'statusCode' and 'body' are required
21+
# # api-gateway-simple-proxy-for-lambda-output-format
22+
# Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
23+
24+
# begin
25+
# response = HTTParty.get('http://checkip.amazonaws.com/')
26+
# rescue HTTParty::Error => error
27+
# puts error.inspect
28+
# raise error
29+
# end
30+
31+
{
32+
statusCode: 200,
33+
body: {
34+
message: "Hello World!",
35+
# location: response.body
36+
}.to_json
37+
}
38+
end

0 commit comments

Comments
 (0)