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%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Martijn van der Kleijn 7b2f892c11
All checks were successful
ci / lint (push) Successful in 27s
ci / test (push) Successful in 23s
release / lint (push) Successful in 27s
release / test (push) Successful in 21s
release / build-image (push) Successful in 1m6s
fix: typo in healthz endpoint
Signed-off-by: Martijn van der Kleijn <martijn@opencommit.eu>
2026-08-04 23:20:44 +02:00
.forgejo/workflows ci: fix workflow permissions 2026-08-04 02:41:47 +02:00
.gitignore intial commit 2026-07-29 09:41:51 +02:00
.golangci.yml chore: minor fixes based on linting 2026-08-04 01:14:36 +02:00
Dockerfile intial commit 2026-07-29 09:41:51 +02:00
go.mod intial commit 2026-07-29 09:41:51 +02:00
LICENSE docs: add license file 2026-08-04 22:11:51 +02:00
main.go fix: typo in healthz endpoint 2026-08-04 23:20:44 +02:00
main_test.go fix: typo in healthz endpoint 2026-08-04 23:20:44 +02:00
README.md fix: typo in healthz endpoint 2026-08-04 23:20:44 +02:00

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)