A simple HTTP/1.1 server written in the Yo programming language.
- Async I/O — Uses
io.awaitwithIOalgebraic effect for non-blocking TCP networking - Algebraic effects —
Exceptioneffect for structured error handling (per-connection error isolation) - HTTP parsing — Hand-written HTTP/1.1 request parser (method, path, headers, body)
- Routing — Simple path-based router with multiple response types
| Path | Description |
|---|---|
/ |
HTML welcome page with links to other routes |
/hello |
Plain text Hello, World! |
/json |
JSON response with language info |
/echo |
Echo back request method, path, and headers as HTML |
* |
404 Not Found |
yo build
./yo-out/bin/http_server_demo_yoThen visit http://localhost:8080 or test with curl:
curl http://localhost:8080/
curl http://localhost:8080/hello
curl http://localhost:8080/json
curl -H "X-Custom: test" http://localhost:8080/echohttp_server_demo_yo/
├── build.yo # Build configuration
├── src/
│ └── main.yo # HTTP server implementation (~250 lines)
└── README.md
async/awaitvia theIOeffect andio.await- Algebraic effects with
given/Exception/escapefor error handling - TCP server with
TcpListener.bind,listener.accept,stream.read/write - String processing with
split,index_of,substring,trim - Pattern matching with
matchandcond while runtime(true)for infinite accept loops- Template strings for HTML/JSON response building