Small Ruby app with:
/: a simple UI that lists all APIs available in the app- 3 JSON APIs:
GET /api/pingGET /api/timePOST /api/echo
Requirements: Ruby 3.3+
bundle install
bundle exec ruby app.rbThen open:
- UI:
http://localhost:9000/
curl -s http://localhost:9000/api/pingcurl -s http://localhost:9000/api/timecurl -s -X POST http://localhost:9000/api/echo \
-H 'Content-Type: application/json' \
-d '{"hello":"world"}'Build:
docker build --platform=linux/amd64 -t ruby-rest-api .Run:
docker run --rm -p 9000:9000 ruby-rest-apiThen open:
- UI:
http://localhost:9000/
PORT: port to listen on (default:9000)BIND: bind address (default:0.0.0.0)
Example:
PORT=8080 bundle exec ruby app.rb