# Gin From Zero

If you write a web service in Go, there's a very good chance it's a Gin service. Gin is the most popular
Go web framework: a thin, fast layer over the standard library's `net/http` that hands you the things you
write by hand otherwise - a real router with URL parameters, JSON binding and validation, middleware, and
tidy response helpers - without hiding what Go is actually doing underneath. That last part matters: Gin
is *small*. Once you've seen it, it reads as "net/http with the boring parts done for you," not magic.

The mental model is one object and one value. The **engine** (`gin.Engine`) is your application - you
register routes on it and run it. Every request that arrives gets a **context** (`*gin.Context`) - one
value that carries the request, the response writer, the parsed parameters, and the helpers to read input
and write output. Learn to think "engine holds the routes, context handles the request," and the whole
framework falls into place.

> 📝 This teaches the **framework** - it assumes you know **Go**: functions, structs, methods, interfaces,
> and `error` ([Go From Zero](/guides/go-from-zero)). It pairs with [What a Framework Even Is](/guides/what-a-framework-even-is),
> and it's worth comparing with [Echo](/guides/echo-from-zero) and [chi](/guides/chi-from-zero); the
> [net/http roots guide](/guides/web-services-with-only-net-http) shows what Gin is built on. Gin compiles
> and runs as a Go program, so examples are shown with the commands to run them yourself.

## How to read this

Read in order - it grows one service (a small **tasks API**) from a single route to a structured, tested,
deployable REST API. Phases carry difficulty badges.

## The phases

**Part 1 - The core (🟢 Basic)**
1. **[What Gin Is & Your First Server](01-what-gin-is.md)** 🟢 - the engine, the context, and a running server in a few lines.
2. **[Routing & Route Groups](02-routing-and-groups.md)** 🟢 - methods, path and query params, wildcards, and grouping routes.
3. **[Binding & Validating Input](03-binding-and-validation.md)** 🟡 - `ShouldBindJSON`, struct tags, and the built-in validator.

**Part 2 - A real API (🟡 → 🔴)**
4. **[Responses & Rendering](04-responses-and-rendering.md)** 🟡 - `c.JSON`, status codes, HTML templates, and static files.
5. **[Middleware](05-middleware.md)** 🟡 - what middleware is, `c.Next()`, the built-in Logger/Recovery, and writing your own.
6. **[Building a REST API](06-building-a-rest-api.md)** 🟡 - full CRUD for the tasks resource, wired end to end.
7. **[Error Handling & Project Structure](07-errors-and-structure.md)** 🔴 - `c.Error`, `AbortWithStatusJSON`, and structuring beyond one file.

**Part 3 - Ship it (🟡 → 🟢)**
8. **[Testing & Production](08-testing-and-production.md)** 🟡 - `httptest` with Gin, test mode, graceful shutdown, and deployment.
9. **[Where to Go Next](09-where-to-go-next.md)** 🟢 - Gin vs Echo/chi/Fiber, when plain net/http is enough, and what to build.

> The throughline: an **engine** holds your routes, a **context** handles each request, and middleware
> wraps the chain. Hold those three and Gin is a small, fast tool you fully understand.
