Skip to content

catalystbyzoho/example-ruby-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby API + UI (Sinatra)

Small Ruby app with:

  • /: a simple UI that lists all APIs available in the app
  • 3 JSON APIs:
    • GET /api/ping
    • GET /api/time
    • POST /api/echo

Run locally

Requirements: Ruby 3.3+

bundle install
bundle exec ruby app.rb

Then open:

  • UI: http://localhost:9000/

APIs

GET /api/ping

curl -s http://localhost:9000/api/ping

GET /api/time

curl -s http://localhost:9000/api/time

POST /api/echo

curl -s -X POST http://localhost:9000/api/echo \
  -H 'Content-Type: application/json' \
  -d '{"hello":"world"}'

Docker

Build:

docker build --platform=linux/amd64 -t ruby-rest-api .

Run:

docker run --rm -p 9000:9000 ruby-rest-api

Then open:

  • UI: http://localhost:9000/

Configuration

  • PORT: port to listen on (default: 9000)
  • BIND: bind address (default: 0.0.0.0)

Example:

PORT=8080 bundle exec ruby app.rb

About

Demo ruby app deployed on Catalyst Appsail

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published