Sha256: 0b28cde02d0fd2bcd72e2216facf47eb88eaa69967ae887ba9d6697eef492393

Contents?: true

Size: 797 Bytes

Versions: 3

Compression:

Stored size: 797 Bytes

Contents

# require 'cool-gem'
require 'json'

# To deploy this function, cd into its folder and run:
# faastruby deploy-to WORKSPACE_NAME
def handler event
  data = event.body ? JSON.parse(event.body) : {}
  # FUNCTION RESPONSE
  #
  # You can render text, json, yaml, html or js. Example:
  # render html: '<p>Hello World!</p>'
  # render yaml: {hello: 'world!'}
  #
  # Status:
  # The default status is 200. You can set a custom status like this:
  # render json: {error: 'Could not perform the action'}, status: 422
  #
  # Headers:
  # The 'Content-Type' header is automatically set when you use 'render'.
  # You can set custom headers using a hash with string keys. Example:
  # render text: 'It Works!', headers: {'TransactionId' => 23928}
  render text: "Hello, #{data['name'] || 'World'}!\n"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faastruby-0.3.8 templates/ruby/example/handler.rb
faastruby-0.3.7 templates/ruby/example/handler.rb
faastruby-0.3.6 templates/ruby/example/handler.rb