Files
fx-serverless/examples/functions/Ruby/README.md
Ahsan Nabi Dar d91a7a09e3 Update README.md (#619)
fix file name in example
2021-06-10 18:43:14 +08:00

962 B
Vendored

Make a Ruby function a service with fx

Write a function like,

def fx(ctx)
  ctx[:response].body = "hello world"
end

then deploy it with fx up command,

$ fx up -p 8080:3000 func.rb

test it using curl

$ curl 127.0.0.1:8080

HTTP/1.1 200 Created
Connection: Keep-Alive
Content-Length: 11
Content-Type: text/html;charset=utf-8
Date: Thu, 08 Aug 2019 02:39:55 GMT
Server: WEBrick/1.4.2 (Ruby/2.6.3/2019-04-16)
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

hello world

ctx

The ctx object is a Hash have contains request, response, status, and headers of Sinatra