Gin: HTTP web framework for Go
Fast HTTP router with JSON binding and middleware support.
Learn more about gin
Gin is a web framework for Go that handles HTTP request routing and response rendering. It implements a middleware system similar to Express.js and uses httprouter as its underlying router to minimize memory allocations during request processing. The framework includes features like automatic JSON/XML binding, template rendering, and panic recovery middleware. Common applications include REST API development, microservice construction, and web application backends where concurrent request handling is required.
Zero-Allocation Routing
Uses httprouter to perform request routing without heap allocations, reducing garbage collection pressure. Delivers lower memory overhead and consistent performance under high concurrent load compared to frameworks that allocate per request.
Middleware and Grouping
Compose cross-cutting concerns like logging and authentication through a chainable middleware system. Route grouping organizes related endpoints and applies common middleware to subsets, reducing code duplication.
Built-in Request Handling
Automatic JSON and XML binding with validation eliminates manual parsing boilerplate. Includes template rendering for HTML responses and recovery middleware that catches panics to prevent server crashes.
r := gin.Default()
r.GET("/users/:id", func(c *gin.Context) {
id := c.Param("id")
c.JSON(200, gin.H{
"user_id": id,
"name": "John Doe",
})
})
r.Run(":8080")Feature release adding HTTP/3 support, custom JSON codecs, and new binding helpers; no breaking changes noted.
- –Enable HTTP/3 with quic-go by calling the new HTTP/3 server method; requires quic-go dependency.
- –Use custom JSON codecs at runtime or bind plain text with BindPlain; form binding now supports default values and arrays.
Refactors HTTPS security configuration and code organization with no documented breaking changes or new requirements.
- –Review HTTPS settings as internal security handling was strengthened, though specifics are not detailed in release notes.
- –Release notes do not specify API changes, deprecations, or migration steps required for this patch.
Feature release adding proxy auth, custom binding unmarshalers, and option funcs; upgrades golang.org/x/crypto to 0.17.0 and protobuf for CVE-2024-24786.
- –Use `BasicAuthForProxy` for proxy-server authentication or `OptionFunc` with `With` to configure engine instances functionally.
- –Implement custom `BindUnmarshaler` interface to override default binding behavior for specific types in request parsing.
See how people are using gin
Top in Backend & APIs
Related Repositories
Discover similar tools and frameworks used by developers
erpnext
Full-featured ERP system built on Frappe Framework.
dompdf
CSS 2.1 compliant HTML layout and rendering engine.
graphiql
Browser-based GraphQL IDE with language service tooling.
whatsmeow
Go client library for WhatsApp web multidevice protocol.
axios
Promise-based HTTP client with unified browser and Node.js interface.