Gofi is a lightweight, high-performance RSS/Atom-to-JSON proxy service written in Go. It fetches any public feed URL, normalizes it into a simple JSON schema, and serves it via an HTTP API—with built-in Redis caching, per-token access control, and rate-limiting.
-
🔗 RSS/Atom Support
Parses RSS 2.0, Atom, and RDF feeds using gofeed. -
⚡ Fast JSON Output
Returns a structured JSON payload with feed metadata and items: -
🔒 Token-Based Auth
Admins can issue tokens for clients. Every request to/v1/feed
must present a validBearer
token. -
⏱️ Rate-Limiting
Per-token rate limits (e.g. “1000 requests per hour”) enforced via ulule/limiter + Redis. -
📦 Redis Caching
Feed responses are cached in Redis (15 min TTL by default) to reduce upstream calls. -
🐳 Docker-Ready
Single Dockerfile +docker-compose.yml
spins up Gofi + Redis in seconds.
feedjson/
├── cmd/feedjson/
│ └── main.go — application entrypoint
├── internal/
│ ├── api/
│ │ └── router.go — HTTP routes & handlers
│ ├── auth/
│ │ ├── middleware.go — bearer-token check
│ │ └── store.go — Redis token store
│ ├── cache/
│ │ └── cache.go — Redis client & helpers
│ ├── config/
│ │ └── config.go — env-var loader
│ ├── parser/
│ │ └── parser.go — feed fetching & parsing
│ ├── ratelimit/
│ │ └── middleware.go — rate-limit setup
│ └── model/
│ └── feed.go — JSON response schemas
├── Dockerfile
├── docker-compose.yml
├── go.mod
├── README.md
└── .gitignore
- Go 1.24+
- Docker & Docker Compose
- (Optional) Local Redis instance if not using Docker
git clone https://github.com/zeroCoder1/feedjson.git
cd feedjson
go mod tidy
Create a .env
(or set in your shell / compose) with:
# Redis connection
REDIS_ADDR=redis:6379
REDIS_PASSWORD=
REDIS_DB=0
# Rate limit (e.g. 100 requests per hour)
RATE_LIMIT=100-H
# Admin secret for token issuance
ADMIN_SECRET=your-admin-secret
# HTTP bind port
PORT=8080
docker-compose up --build -d
- Redis on port 6379
- Gofi on port 8080
curl -i -X POST http://localhost:8080/v1/tokens -H "X-Admin-Token: your-admin-secret"
Response (HTTP 201):
{"token":"3fa85f64-5717-4562-b3fc-2c963f66afa6"}
curl -i -H "Authorization: Bearer 3fa85f64-5717-4562-b3fc-2c963f66afa6" "http://localhost:8080/v1/feed?rss_url=https://blog.golang.org/feed.atom&count=5"
- 200 OK with JSON payload.
- 401 Unauthorized if token is missing/invalid.
- 429 Too Many Requests if rate limit exceeded.
Env Var | Default | Description |
---|---|---|
REDIS_ADDR |
localhost:6379 |
Redis server address |
REDIS_PASSWORD |
― | Redis password (if any) |
REDIS_DB |
0 |
Redis database index |
RATE_LIMIT |
1000-H |
Rate (e.g. 100-H , 5000-D , etc.) |
ADMIN_SECRET |
― | Secret to protect token-issuance API |
PORT |
8080 |
HTTP server port |
-
Unit tests:
go test ./internal/parser go test ./internal/cache go test ./internal/auth
-
Integration:
Run against local Redis and verify endpoints withcurl
.
- Fork the repo & create a feature branch
git checkout -b feature/your-feature
- Write code + tests
go fmt
&go vet
- Open a PR & reference related issue
Please follow the Go project layout and write clear, concise commit messages.
This project is licensed under the MIT License.
See LICENSE for details.