Pengenalan Instalasi Konfigurasi Contoh GitHub

Contoh Implementasi

Simple Rack App

# config.ru
run lambda { |env|
  [200, {"Content-Type" => "text/html"}, 
   ["<h1>Halo Dunia!</h1>"]]
}

JSON API

# config.ru
require 'json'
run lambda { |env|
  [200, {"Content-Type" => "application/json"}, 
   [{status: "ok", data: "Hello"}.to_json]]
}

Static Site Server

EksaServer sangat bagus untuk melayani file statis dengan middleware standard Rack. Cukup tentukan folder root dan file index Anda.

# config.ru
use Rack::Static, urls: [""], root: "public", index: "index.html"
run lambda { |env| [404, {"Content-Type" => "text/html"}, ["Not Found"]] }