Skip to content

hsnamr/Scalable-Coffee-Pot-Control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scalable Coffee Pot Control (HTCPCP)

An HTCPCP/1.0 server over HTTP implemented in Scala with http4s.

Features

  • Methods: BREW, GET, PROPFIND, WHEN, plus HEAD and OPTIONS
  • Resources: Coffee pots as URIs, e.g. /pot-1, /pot-2; teapots as /teapot-* (return 418 for coffee)
  • Status codes: 200, 202, 400, 404, 406, 418, 500 as appropriate
  • Content types: message/coffeepot, application/coffee-pot-command, application/json for BREW body

Run

sbt run

Server listens on 0.0.0.0:8080. Main class: htcpcp.HtcpcpServer.

Test

sbt test

API examples (curl)

List all pots

curl -s http://localhost:8080/
curl -s http://localhost:8080/pots

Start brewing (message/coffeepot)

curl -i -X BREW http://localhost:8080/pot-1 \
  -H "Content-Type: message/coffeepot" \
  -d "start"

Start brewing (JSON)

curl -i -X BREW http://localhost:8080/pot-1 \
  -H "Content-Type: application/json" \
  -d '{"beverage":"coffee","strength":"normal","additives":[]}'

Get pot status

curl -s http://localhost:8080/pot-1

PROPFIND (capabilities)

curl -s -X PROPFIND http://localhost:8080/pot-1

Schedule brew (WHEN)

curl -i -X WHEN http://localhost:8080/pot-1 -d "2025-02-06T08:00:00Z"

418 I'm a teapot (brew coffee on a teapot)

curl -i -X BREW http://localhost:8080/teapot-1 \
  -H "Content-Type: message/coffeepot" \
  -d "start"

Stack

  • Scala 3.3
  • http4s 0.23 (Ember server)
  • Circe (JSON)
  • Cats Effect 3 (IO)
  • ip4s (host/port literals)

License

See LICENSE.

About

A Scala implementation of the Hyper Text Coffee Pot Control Protocol RFC 2324

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages