A demo project showing how to embed Feather in a Go application
This is a toy HTTP server that uses Feather scripts to handle requests, demonstrating Feather's embedding capabilities.
demo.webm
- Embedding the Feather interpreter in a Go application
- Exposing Go functions as Feather commands
- Live code reloading via a built-in REPL
- Template rendering from scripts
- Streaming responses (Server-Sent Events)
go build
./feather-httpdVisit http://localhost:8080 to see the server running.
The server exposes a REPL on port 8081. Connect with readline support using rlwrap and nc:
rlwrap nc localhost 8081Or use the web-based REPL at http://localhost:8080/_repl.
feather-httpd/
├── main.go # HTTP server setup, REPL server, and Feather interpreter initialization
├── commands.go # Custom commands exposed to Feather scripts (route, respond, template, etc.)
├── state.go # Request/response state management and route registry
├── json.go # JSON parsing and encoding utilities
├── feather-httpd.tcl # Example Feather script — your application logic lives here
└── templates/ # HTML templates directory
┌─────────────────────────────────────────────────────────────┐
│ Go Runtime │
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ HTTP Server │ │ Feather Interpreter │ │
│ │ (port 8080) │───▶│ • Evaluates route handlers │ │
│ └─────────────────┘ │ • Manages templates │ │
│ ┌─────────────────┐ │ • Processes JSON │ │
│ │ REPL Server │───▶│ │ │
│ │ (port 8081) │ └─────────────────────────────────┘ │
│ └─────────────────┘ │
└─────────────────────────────────────────────────────────────┘
- main.go boots the HTTP server and initializes the Feather interpreter
- commands.go registers Go functions as Feather commands (
route,respond,template, etc.) - state.go maintains thread-safe state for routes, templates, and active connections
- feather-httpd.tcl is loaded at startup — define your routes here
# Define a simple route
route GET /hello {
respond "Hello, World!"
}
# Use templates with data
route GET /greet/:name {
template respond greeting name [param name]
}
# Return JSON
route GET /api/status {
header Content-Type application/json
respond [json encode {status ok}]
}Visit feather-lang.dev for Feather language documentation.