fiber-rest-api

Featured

Use when adding or changing a Go HTTP endpoint with Fiber - thin handlers, centralized domain-error-to-status mapping, boundary validation, and neighbor-consistent middleware

API & Backend 91 stars 13 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 89/100

Stars 20%
65
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Fiber REST API Patterns ## Overview A Fiber handler is a translator: HTTP in → service call → HTTP out. Business logic never lives there. The recurring defects are fat handlers, per-handler error mapping that drifts, and endpoints that quietly drop the auth middleware their neighbors have. **Core principle:** Handlers parse, validate, delegate, and map. Nothing else. ## Rules - `github.com/gofiber/fiber/v2` with the Goccy JSON encoder. - **Thin handlers:** parse/validate input → call the application service → map result to response DTO. No business logic, no SQL, no cross-entity rules in the handler. - **Explicit DTO structs** aligned with domain types — never `map[string]any`. Annotate every handler for Swagger. - **Validate and bound all input at the boundary:** lengths, ranges, enum values, UUID parsing. Reject early with 400 and a field-specific message. - **Map domain errors to status in ONE place** (a shared error handler / mapper), not per handler, so the mapping can't drift. - **One error JSON shape** across the API; message actionable for the caller, internal detail to logs. - **New endpoints get the SAME middleware chain** (auth, logging, request-id) as their neighbors — copy the adjacent route's wiring, don't invent one. ## Status codes | Code | When | |------|------| | 200 / 201 | success / created | | 400 | validation / malformed input | | 401 / 403 | unauthenticated / forbidden | | 404 | resource missing | | 409 | conflict (duplicate, invalid transition...

Details

Author
makifbaysal
Repository
makifbaysal/tasktrooper
Created
1 weeks ago
Last Updated
today
Language
Go
License
Apache-2.0

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

mir-backend-go-fiber

Make It Right (Fiber module). Fiber web framework reliability augmentation for Go backends, covering Fiber v3 (current) and v2 (still patched). Chains: mir-backend (generic gates) -> mir-backend-go (Go runtime) -> this (Fiber library mechanics). Adds the mechanical footguns the runtime-agnostic tiers omit: fiber.Ctx and every value read from it (Body, Params, Query, Headers) are pooled and reused after the handler returns, so retaining them corrupts or discloses another request's data; the v2->v3 API rewrite that AI mixes up (Ctx is now an interface, BodyParser became c.Bind().Body(), c.Context() returns a context.Context, TrustedProxies became TrustProxyConfig); c.Bind() silently skips validation when fiber.Config.StructValidator is nil; fasthttp's incompatibility with net/http middleware; and graceful shutdown via ListenConfig.GracefulContext or app.ShutdownWithContext, which hangs on keep-alive connections when ReadTimeout is 0. TRIGGER only when the Go backend uses the Fiber framework - building, reviewin

15 Updated 3 weeks ago
anantbhandarkar
API & Backend Solid

loom-api-design

Designs RESTful APIs, GraphQL schemas, and RPC interfaces for consistency, usability, and scalability.

56 Updated today
cosmix
API & Backend Listed

api-design

REST/HTTP API design patterns — resource naming, status codes, pagination, filtering, errors, versioning, idempotency. Use when designing or reviewing API endpoints.

28 Updated 3 days ago
jedbjorn