How robby031/r2 works
This is a Go HTTP API for managing files in Cloudflare R2: the server initializes configuration and storage, then routes file operations through Gin controllers to the storage client. The API supports uploads, deletion, presigned URLs, listing, checksum verification, and usage reporting; the storage layer also enforces a capacity limit and caches reads. The cache’s interaction with storage is explicit in the excerpt; other internal S3 operations are summarized at the storage component. The README is empty, so feature coverage relies on the sampled controllers and storage code.
Main entry points: storage.go Storage client · main.go HTTP server · router.go Gin router · controllers.go File controllers
Components 8
HTTP API
- Gin router
internal/router.go - File controllers
internal/controllers.go
Object storage
- Storage client
storage/storage.go - Read cache
storage_cache/cache.go
Runtime setup
- HTTP server
main.go - Environment config
config/config.go
Other components
- API client
- Cloudflare R2
Connections 8
- API client → HTTP server: sends requests
- HTTP server → Environment config: loads settings
main.go - HTTP server → Gin router: serves routes
main.go - Environment config → Storage client: initializes
config/config.go - Gin router → File controllers: dispatches
internal/controllers.go - File controllers → Storage client: calls operations
internal/controllers.go - Storage client → Read cache: loads and invalidates
storage/storage.go - Storage client → Cloudflare R2: reads and writes objects
storage/storage.go