Sha256: a954cd70ce1a5d70698a6982c6b50d21230c82300e2fc03f54f0d1abcba5c25c

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

Contents

# require "cool-shard"
require "json"

# To deploy this function, cd into its folder and run:
# faastruby deploy-to WORKSPACE_NAME
def handler(event : FaaStRuby::Event) : FaaStRuby::Response
  # event.body : String | Nil
  # event.headers : Hash(String, String)
  # event.context : String | Nil
  # query_params : Hash(String, String)
  name = event.body ? JSON.parse(event.body.not_nil!)["name"] : "World"
  # 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(String, String). Example:
  # render text: "It Works!", headers: {"TransactionId" => 23928}
  render text: "Hello, #{name}!\n"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faastruby-0.4.1 templates/crystal/example/src/handler.cr
faastruby-0.4.0 templates/crystal/example/src/handler.cr
faastruby-0.3.8 templates/crystal/example/src/handler.cr