RSS-to-JSON bridge in Go. Fetches an RSS feed, strips HTML from descriptions, and serves the results as a JSON API with human-friendly relative dates. No external dependencies.
https://opencommit.eu/opencommit/newsbridge
- Go 98.3%
- Dockerfile 1.7%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| .gitignore | ||
| .golangci.yml | ||
| Dockerfile | ||
| go.mod | ||
| LICENSE | ||
| main.go | ||
| main_test.go | ||
| README.md | ||
newsbridge
Go RSS-to-JSON bridge. Fetches an RSS feed, caches it in memory, and serves it as JSON over HTTP.
Zero external dependencies.
Quick start
RSS_URL=https://example.com/feed.xml go run .
curl http://localhost:8080/news/v1/json
Configuration
| Env | Default |
|---|---|
RSS_URL |
http://static-site.forgejo.svc.cluster.local/en/news/index.xml (internal K8s) |
SCRAPE_INTERVAL |
300s (Go duration) |
LISTEN_ADDR |
:8080 |
MAX_ITEMS |
4 |
Endpoints
| Path | Method | Response |
|---|---|---|
/news/v1/json |
GET | JSON posts array |
/news/v1/healthz |
GET | ok / not ready / stale |
/news/v1/healthz returns 503 if the cache was never populated or the last successful fetch was more than 10 minutes ago.
Development
go build -o newsbridge . # dev build
go test ./... -v # run tests
go test -coverprofile=coverage.out && go tool cover -html=coverage.out # coverage
Docker
docker build -t newsbridge .
docker run -p 8080:8080 newsbridge
Architecture
- Fetches RSS on startup (blocks until complete), then refreshes in the background at
SCRAPE_INTERVAL - Parses XML, strips HTML from descriptions, returns JSON
- In-memory cache with
sync.RWMutex - Graceful shutdown via
SIGINT/SIGTERM(5s drain timeout)