Fiber API Starter for Go

A small Fiber v2 API starter in Go 1.25, running on the fasthttp engine, for developers who like Express-style routing in Go. It includes a JSON root route, a health check, a slog request logger, panic recovery, graceful shutdown and in-memory route tests.

by Light CloudREST APIs

Features

  • Fiber v2.52 on fasthttp, with the start-up message turned off and a 10 second ReadTimeout
  • GET / answers {"message": "Hello from Fiber on Light Cloud"} and GET /health answers {"status": "ok"}
  • A hand-written Fiber middleware calls the app's error handler before logging, so 404 and 500 lines show the real status
  • Fiber's recover middleware turns a panic into a 500
  • Graceful shutdown on SIGTERM through app.ShutdownWithTimeout, with a 10 second drain
  • Table-driven tests run requests through app.Test in memory, covering /, /health and an unknown route
  • make run, make test (go vet plus go test) and make build for a static binary

Tech stack

What you need

  • Free plan: it runs as a server app, and the Free plan includes 3 server apps
  • To run it locally: Go 1.25 or newer and make
  • No API keys: it starts with nothing to configure

About

Fiber is built on fasthttp rather than net/http, so handlers take a *fiber.Ctx, and the template's request logger is a short Fiber handler instead of a net/http wrapper. Keeping fiber.New, middleware and routes in internal/server/server.go means a new endpoint is one handler in handlers.go plus one app.Get line. Light Cloud builds the module, runs it as a container listening on PORT, and redeploys on each push to your copy.

FAQ

How do I add a new route in Fiber?

Write a handler with the signature func(c *fiber.Ctx) error in internal/server/handlers.go and register it in server.New, for example app.Get("/items/:id", getItem). Read the value with c.Params("id") and reply with return c.JSON(item).

Can I use net/http middleware with Fiber?

Not directly, because Fiber runs on fasthttp. Use Fiber's own middleware under github.com/gofiber/fiber/v2/middleware, or the adaptor package, and copy any value from *fiber.Ctx you need after the handler returns, since Fiber reuses it.

How do I add CORS to a Fiber API?

Import github.com/gofiber/fiber/v2/middleware/cors and add app.Use(cors.New()) in server.New, next to the recover middleware the template already uses.

Can I deploy this Fiber app without Light Cloud?

Yes. make build writes a static binary to bin/server; run it with PORT set on any server or copy it into a minimal container image.

Fiber or Echo: which Go starter should I pick?

Pick Fiber if you want Express-style handlers and fasthttp; pick Echo if you want to stay on net/http and its middleware ecosystem. Both starters have the same routes, logging and shutdown, so the code is easy to compare.

Price
Free
Framework
Fiber · Go
Plan
Free
Updated

Related templates

All rest api starters