A Gin 1.12 REST API starter for Go 1.25, for developers who want Gin's router and handler style with only the middleware they choose. It includes / and /health routes, slog request logging, gin.Recovery, a GIN_MODE switch, graceful shutdown and table-driven route tests.
by Light CloudREST APIs
server.New in internal/server returns the Gin engine, and main.go sets the Gin mode and hands that engine to a plain http.Server, which gives you a header timeout and a proper shutdown that Gin's own Run does not. Starting from gin.New() keeps the logging and recovery chain visible in one line. The usual next steps are route groups such as r.Group("/api/v1") and handlers that read c.Param and answer with c.JSON. There is no Dockerfile: on Light Cloud the Go module is built and run as a container on the platform's PORT, and every push to your copy redeploys.
Write a handler func(c *gin.Context) in internal/server/handlers.go and register it in server.New, for example r.GET("/items/:id", getItem). Read the value with c.Param("id") and answer with c.JSON.
In server.New, create v1 := r.Group("/api/v1") and register routes on it, such as v1.GET("/items", listItems). Middleware passed to r.Group runs only for that group.
In debug Gin prints every registered route and warnings at start; in release it stays quiet. The app defaults to release when GIN_MODE is unset.
Yes. It is a plain Go module with no Light Cloud code: build it with make build and run ./bin/server with PORT set on any server or container platform.
Use the gin-postgresql-crud-api template, which connects with pgx. On a paid Light Cloud plan, deploying it creates the database and sets the DB_HOST, DB_NAME, DB_USER and DB_PASSWORD variables.
Start a Go CRUD API on PostgreSQL with Gin, pgx, input validation and route tests
Start a Go JSON API on the standard library alone, with logs, tests and a Dockerfile
Start a Go API on Echo with request logs, error handling and graceful shutdown in place