Packages
Full API reference lives on pkg.go.dev. Each package below links to its API docs.
config— load env vars into typed structs withdefault/requiredtags.logger— structured logger based on zerolog.response— standardized JSON response helpers.parser— Bun pagination/search query modifiers, including keyset (cursor) pagination (Keyset,EncodeCursor/DecodeCursor).pagination— paginated result envelope with page metadata: offset (NewPagination) and cursor (CursorPage/NewCursorPage, forward + backward, RFC 5988LinkHeader) variants.validator— struct validation with custom rules and JSON field names.bind— parse and validate a request body/query/params intoTin one call; writes400/422on failure.jwt— JWT generation and validation helpers.retry— generic retry with exponential backoff + jitter:Do/DoValue[T]with attempts, delay/max-delay, multiplier, jitter, and aWithRetryIfpredicate.http— context-aware JSON HTTP client with retry, an optional circuit breaker (WithCircuitBreaker), and context header propagation (WithContextHeader), plusPostFormandPostMultipart(file upload).redis— Redis wrapper withRemembercache-aside (singleflight-deduped against cache stampede) plusDelete/Exists/Expire/TTLand bulk/atomic ops (MSet/MGet/Incr/Decr/SetNX/GetSet). Includes aStorageadapter (fiber.Storage) for Redis-backed rate limiting, andPublish/Subscribe[T]pub/sub for cross-instance events.
redis.NewStorage(client) adapts a go-redis client to fiber.Storage — pass it as bootstrap.Options.RateLimitStorage for a rate limiter consistent across instances.
- lock — single-instance Redis distributed mutex: TryAcquire/Acquire/Do (run-once across replicas) with owner-only Release/Extend. Guards single-execution of scheduler/cron work in multi-replica deploys.
- outbox — transactional outbox: Enqueue an event in the same Bun transaction as your business write, and a background Relay publishes pending events at-least-once (NewRedisPublisher, optional single-relay coordination via lock). Solves the dual-write problem.
- inbox — idempotent-consumer dedup: Once(ctx, db, messageID, fn) records a marker and runs the handler in one transaction so a message is processed exactly once under at-least-once delivery. Consumer-side complement to outbox.
- events — in-process typed event bus: Subscribe[T] / Publish[T] over a Bus, synchronous by default (joined errors) with an opt-in async mode (WithAsync). Complements outbox for in-memory, intra-process fan-out.
- featureflag — runtime feature flags (boolean, percentage rollout via stable hashing, per-user/group targeting) through a pluggable Provider: Static, Rules, and Redis (live toggling), plus a Fiber Middleware + Enabled(c, flag) helper.
- audit — structured audit log: a Recorder writes actor/action/target Entry records through a pluggable Sink (NewBunSink + Migrate + List), with a Fiber FromRequest helper that prefills actor/IP/request-id.
- cache — generic in-memory cache Cache[V] with TTL, LRU max-size eviction, and singleflight GetOrLoad. Complements redis.Remember for hot data without a network round-trip.
- ratelimit — Redis-backed token-bucket rate limiter: per-key buckets with cost-per-request (Allow) and a Fiber Middleware (429 + Retry-After + X-RateLimit-*). Adds cost + arbitrary per-key rules over Fiber's window limiter.
- apikey — API-key authentication (distinct from JWT auth): hash a presented key and resolve its identity + scopes via a pluggable Store (MapStore built in), with Generate/Hash, a Fiber Middleware, RequireScope, and FromContext/HasScope helpers.
- slug — unique URL-safe slug generator backed by a Bun database.
- uploader — local file uploader with size and MIME limits. Includes S3Uploader for S3-compatible storage (AWS S3, MinIO, R2).
- middleware — recover, request logging, and request-id middleware.
- context — request context, request-id, and type-safe local accessors.
- database — Bun connector with Postgres/SQLite dialect auto-detection (plus WithTracing).
- dbresolver — explicit read/write split over Bun: New(primary, replicas...) with Writer() (primary) and Reader() (round-robin replica, primary when none), plus Ping/Close.
- migrate — versioned migrations with bun/migrate and a ready cobra command.
- auth — JWT bearer auth, bcrypt, refresh tokens, scopes, and teams/roles helpers.
- health — liveness (/livez) and readiness (/readyz) endpoints, dependency probes (PingBun/PingRedis/PingHTTP/PingTCP), and a ReadinessGate for drain-on-shutdown.
- metrics — Prometheus request metrics middleware + /metrics handler.
- tracing — OpenTelemetry tracing setup (OTLP/HTTP) + Fiber spans.
- jobs — Redis-backed background jobs (asynq) + asynqmon monitoring mount. Includes Scheduler for cron-triggered (periodic) jobs.
- mailer — transactional email: pluggable Sender (SMTP/log/memory) + template render.
- server — signal-based graceful shutdown via RunGraceful, plus RunGracefulWithConfig with pre-shutdown hooks and a drain delay.
- apierror — typed HTTP errors (NotFound, Conflict, ...) + a Fiber ErrorHandler that renders them as the JSON envelope; wired by bootstrap automatically.
- webhook — HMAC sign/verify (Stripe-style, replay-protected) + inbound verification middleware.
- openapi — generate an OpenAPI 3.0.3 document from registered routes + reflected request/response structs (json + validator tags), served as /openapi.json with a CDN-backed Swagger UI at /docs. Wired by bootstrap via Options.OpenAPI.
- ws — typed WebSocket Hub[T] with rooms and JSON broadcast on top of gofiber/contrib/websocket; optional Redis backplane (WithRedis) for multi-replica fanout.
- sse — Server-Sent Events: a one-way text/event-stream helper with JSON event encoding.
- i18n — dependency-free internationalization: a message Bundle (nested JSON, {placeholder} substitution, one/other plurals, fallback locale) + locale-detection middleware (query/cookie/Accept-Language) and T/N/Locale helpers. Wired by bootstrap via Options.I18n.
- bootstrap — one-call app wiring: middleware, health, DB, metrics, tracing, security headers (helmet), compression, idempotency keys, OpenAPI docs, graceful shutdown.
- fibrtest — test harness: a fluent HTTP client over *fiber.App (Get/Post/builder), response assertions (ExpectStatus/JSON), plus NewDB (in-memory SQLite Bun) and Token (JWT) helpers.