fiber
Fiber Go web framework inspired by Express. Covers routing, middleware, context, WebSocket, and prefork. Use for Express-like Go development. USE WHEN: user mentions "fiber", "gofiber", "express-like go", "fasthttp go", asks about "fiber middleware", "fiber context", "fiber prefork", "fiber websocket", "go express", "fast go framework" DO NOT USE FOR: Gin projects - use `gin` instead, Echo projects - use `echo` instead, Chi projects - use `chi` instead, standard net/http compatibility required
What this skill does
# Fiber Core Knowledge
> **Full Reference**: See [advanced.md](advanced.md) for validation with go-playground/validator, WebSocket setup, custom error handling, prefork mode, and graceful shutdown.
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `fiber` for comprehensive documentation.
## Basic Setup
```go
package main
import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
})
app.Listen(":8080")
}
```
## Configuration
```go
app := fiber.New(fiber.Config{
Prefork: true, // Multiple processes
StrictRouting: true, // /foo != /foo/
CaseSensitive: true, // /Foo != /foo
BodyLimit: 4 * 1024 * 1024, // 4MB
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
})
```
## Routing
```go
app.Get("/users", listUsers)
app.Get("/users/:id", getUser)
app.Post("/users", createUser)
app.Put("/users/:id", updateUser)
app.Delete("/users/:id", deleteUser)
// Path parameters
app.Get("/users/:id", func(c *fiber.Ctx) error {
id := c.Params("id")
return c.JSON(fiber.Map{"id": id})
})
// Optional parameter
app.Get("/users/:name?", func(c *fiber.Ctx) error {
name := c.Params("name", "anonymous")
return c.JSON(fiber.Map{"name": name})
})
// Route groups
api := app.Group("/api")
v1 := api.Group("/v1")
v1.Get("/users", listUsersV1)
```
## Context - Request Data
```go
app.Post("/users", func(c *fiber.Ctx) error {
// Path params
id := c.Params("id")
idInt, _ := c.ParamsInt("id")
// Query params
page := c.Query("page", "1")
pageInt := c.QueryInt("page", 1)
// Headers
auth := c.Get("Authorization")
// Cookies
session := c.Cookies("session_id")
return c.SendStatus(fiber.StatusOK)
})
```
## Body Parsing
```go
type CreateUserRequest struct {
Name string `json:"name"`
Email string `json:"email"`
}
app.Post("/users", func(c *fiber.Ctx) error {
var req CreateUserRequest
if err := c.BodyParser(&req); err != nil {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
"error": err.Error(),
})
}
return c.Status(fiber.StatusCreated).JSON(req)
})
```
## Middleware
```go
import (
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/limiter"
)
app.Use(recover.New())
app.Use(logger.New())
app.Use(cors.New(cors.Config{
AllowOrigins: "https://example.com",
AllowMethods: "GET,POST,PUT,DELETE",
}))
app.Use(limiter.New(limiter.Config{
Max: 100,
Expiration: 1 * time.Minute,
}))
```
## Health Checks
```go
app.Get("/health", func(c *fiber.Ctx) error {
return c.JSON(fiber.Map{"status": "healthy"})
})
app.Get("/ready", func(c *fiber.Ctx) error {
if err := db.Ping(); err != nil {
return c.Status(fiber.StatusServiceUnavailable).JSON(fiber.Map{
"status": "not ready",
})
}
return c.JSON(fiber.Map{"status": "ready"})
})
```
## When NOT to Use This Skill
- **Gin projects** - Gin has different context API
- **Echo projects** - Echo has different middleware patterns
- **Chi projects** - Chi is stdlib-compatible
- **Standard net/http required** - Fiber uses fasthttp, not net/http
- **gRPC services** - Fiber doesn't support gRPC
## Anti-Patterns
| Anti-Pattern | Why It's Bad | Solution |
|--------------|--------------|----------|
| Not calling `c.Next()` in middleware | Breaks middleware chain | Always call `c.Next()` unless stopping |
| Using `c.Body()` multiple times | Body is consumed | Store body in variable first |
| Missing error handling | Silent failures | Check `BodyParser()` return value |
| Not setting Prefork carefully | May cause issues with state | Only use Prefork without shared state |
| No rate limiting | DDoS vulnerability | Use `limiter` middleware |
## Quick Troubleshooting
| Problem | Diagnosis | Fix |
|---------|-----------|-----|
| Route not found | Wrong method or path | Check exact route registration |
| Body parsing fails | Wrong content-type | Ensure `Content-Type` header is correct |
| CORS errors | Not configured | Use `cors.New()` middleware |
| Middleware not executing | Wrong order | Place before route handlers |
| Prefork issues | Shared state problems | Avoid shared mutable state with Prefork |
## Production Checklist
- [ ] Recovery middleware enabled
- [ ] CORS configured
- [ ] Rate limiting enabled
- [ ] Request body size limit set
- [ ] Timeouts configured
- [ ] Structured logging
- [ ] Health/readiness endpoints
- [ ] Graceful shutdown
- [ ] Input validation
## Reference Documentation
- [Routing](quick-ref/routing.md)
- [Context](quick-ref/context.md)
- [Middleware](quick-ref/middleware.md)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.