ruby http

A Ruby HTTP template for OpenFaaS

12
8
Ruby

ruby-http

This template uses Sinatra internally, and the slim Docker image for Ruby to keep the image small. A native build toolchain is installed, which still results in a smaller image than the standard Ruby image on the Docker Hub.

Ruby version: 3.3.6.

Usage:

faas template pull https://github.com/openfaas/ruby-http
faas new --lang ruby-http homepage

Example:

Edit the homepage/handler.rb file to return some HTML:

class Handler
  def run(body, headers)
    status_code = 200 # Optional status code, defaults to 200
    response_headers = {"content-type" => "text/html"}
    body = "<html>Hello world from the Ruby template</html>"

    return body, response_headers, status_code
  end
end

Add a gem to the homepage/Gemfile if you need additional dependencies.

Deploy:

faas-cli up -f homepage.yml